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

How do I make a part float around while gravity is 0?

Asked by 3 years ago

I am trying to make a 0 gravity game and I already handled the player's 0 gravity script, but I can't seem to make parts float around, whenever I play they always fall to the ground. I haven't tried any scripts for it, instead I was trying to change properties like density and mass to make it float, but none of that worked, although if that is the solution I probably got the numbers wrong.

1 answer

Log in to vote
0
Answered by 3 years ago

Nevermind I figured it out! If you want to see the code for it,

local object = script.Parent;
local bodyForce = Instance.new("BodyForce", object) -- Creating a BodyForce.
local mass = object:GetMass();
local gravity = workspace.Gravity;
bodyForce.Force = Vector3.new(0, 0, 0) -- Setting the force to have no impact at the moment I create it.

function set_Powers(mass, gravity)
    bodyForce.Force = Vector3.new(0, mass * gravity, 0)
end;

while wait() do
    set_Powers(mass, gravity)
end
Ad

Answer this question