Anti-gravity script not working properly

I am trying to create a zero gravity script that uses bodyForce. Basically like the player is floating in space. A good example of this is in Festivereinhard2’s Innovation Space Ship.

The problem is, while the player has no gravity on the Y coordinate, it’s not the same on the X and Z coordinates. (The player only has no gravity moving up and down, not sideways.)

I could not find anything related to an issue like this

The script is in the StarterCharacterScripts folder and is a LocalScript

An example of what my script isn’t able to do (turning sideways)

The character has a bodygyro so it can always stand upright. Maybe you could enable platform stand in the character and manually move it with forces. Also, can’t you just locally turn the workspace’s gravity to 0 instead of adding forces on all of the parts?

I knew there was something that enabled the character to always stand upright but I wasn’t sure what is was. With no mobility from the player, I’m planning on adding a jetpack to give it that mobility. The problem with changing workspace gravity is that it acts very funky and doesn’t do what I want. I will try to destroy the bodygyro and see what happens.

instead of having a bodyforce for every part inside the character

all you need to do is have one VectorForce
https://developer.roblox.com/en-us/api-reference/class/VectorForce

and you can use AssemblyMass to get the mass of the hole character without having to loop every part
https://developer.roblox.com/en-us/api-reference/property/BasePart/AssemblyMass

VectorForce.Attachment0 = character.PrimaryPart.RootRigAttachment
VectorForce.Force = Vector3.new(0, workspace.Gravity * character.PrimaryPart.AssemblyMass, 0)
VectorForce.Parent = character

also bodyfoce is depreciated you should always be using the new bodymovers

1 Like

So here what I have, I’m not sure if I did it right


It is giving me an error that says "RootRigAttachment is not a valid member of Part “Workspace.Player.Head” Should I have specified that this is only r6?

Just change the name of the attachment to match the one in your character

Or you can even make your own attachment and parent it to the part

This video might help you

This is a Roblox mistake that has been on some rigs that are still on the Toolbox.

On R6 make sure that Humanoid.RootPart and Character.PrimaryPart is set to the HumanoidRootPart.

Use Humanoid:ChangeState(Enum.HumanoidStateType.Physics)