Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make player anti-gravity?

Asked by 3 years ago

I've tried making player anti-gravity, and nothing seems to work. I've tried using the classic BodyForce approach (from the HumanoidRootPart and all parts in the character), I've tried BodyVelocity, which does not allow the player to move in the air (not ideal for my situation). Here is my current code:

for _,object in pairs(char:GetChildren()) do
    if object:IsA("BasePart") then
        local bf = Instance.new("BodyForce",object)
        bf.Force = Vector3.new(0,object:GetMass()*workspace.Gravity,0)
    end
end

It does not work until the player goes up with a ramp or something, and lifts them too high.

2 answers

Log in to vote
0
Answered by 3 years ago

You don't need to parent the body force to every body part. Parenting it to just the HumanoidRootPart is sufficient.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can change the gravity value in Workspace to a negative value

example (serverScript)

game.Workspace.gravity = -10

Answer this question