I'm trying to make a Space game. I want there to be gravity but I want the spaceships to float. I scoured this site and Google for some suggestions for code and found this tidbit:
function GetMassOfModel(model) local mass = 0 for i, v in pairs(model:GetChildren()) do if v:IsA('BasePart') or v:IsA('Union') then mass = mass + v:GetMass() end end return mass end script.Parent.BodyForce.force = Vector3.new(0, game.Workspace.Gravity, 0) * GetMassOfModel(script.Parent.Parent)
The problem I'm having is that this doesn't totally negate the gravity. Very slowly, the ship starts to sink and then accelerates. Am I missing a part type that can weigh something? The ship has a VehicleSeat, and several sub-models. Are the sub-models possibly not being counted? I assumed GetChildren() got all children of that object, including those farther down the tree (children of children, etc). Am I wrong about that?