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.
Nevermind I figured it out! If you want to see the code for it,
01 | local object = script.Parent; |
02 | local bodyForce = Instance.new( "BodyForce" , object) -- Creating a BodyForce. |
03 | local mass = object:GetMass(); |
04 | local gravity = workspace.Gravity; |
05 | bodyForce.Force = Vector 3. new( 0 , 0 , 0 ) -- Setting the force to have no impact at the moment I create it. |
06 |
07 | function set_Powers(mass, gravity) |
08 | bodyForce.Force = Vector 3. new( 0 , mass * gravity, 0 ) |
09 | end ; |
10 |
11 | while wait() do |
12 | set_Powers(mass, gravity) |
13 | end |