# How do you change the gravity of a part, but keep the world gravity the same?

1. What do you want to achieve?
I want to change a part’s gravity value while keeping the world’s gravity. I’m working on a car that uses a different gravity value and I’m about to publish it as a free model and I want to give the car a different gravity value automatically rather than making an instruction manual that no one will probably read then call it “broken”.
2. What is the issue?
I don’t know how to change the gravity value of a specific part via script.
3. What solutions have you tried so far?
There were some topics that taught me how to do so, like this one here, but I don’t really understand how they worked, so I ditched it.

The car that I’m going to turn into a free model can be found here and it uses a different gravity value. The gravity value used in this game is 77.

1 Like

BodyVelocity instance which exerts a force upwards on the part along the Y axis.

1 Like
``````local core = script.parent.car.core
local carParts = script.parent.car.core:GetChildren()
local bodyForce = Instance.new('BodyForce', core)
bodyForce.Name = 'Antigravity'
bodyForce.Force = Vector3.new(0, carParts:GetMass() * game.Workspace.Gravity - 20, 0) --lets say the gravity is 80, with this its now 60
``````

this should work

1 Like

I don’t think that’s right. I think it should be this.
Vector3.new(0, carParts:GetMass() * 20, 0)

As a body force, gravity still applies. And the 20 needs to be multiplied by the mass in order to provide adequate force. So this code should reduce gravity by 20.

Does that mean 196.2 (The default world gravity) is now 176.2?

That is what that means. Traditional antigravity code is GetMass() * gravity
If you want to increase force, make the second number negative.

Select the text you want to quote and a little quote button will pop up

1 Like

Ok, so none of the calculations worked, they ended up like this…

Or maybe I didn’t get the code right…

``````for i, v in pairs(car:GetDescendants()) do
if v:IsA("BasePart") then
local bforce = Instance.new('BodyForce', v)
bforce.Name = 'AG'
bforce.Force = Vector3.new(0, v:GetMass() * game.Workspace.Gravity - 119.2, 0)
end
end
``````
``````for i, v in pairs(car:GetDescendants()) do
if v:IsA("BasePart") then
local bforce = Instance.new('BodyForce', v)
bforce.Name = 'AG'
bforce.Force = Vector3.new(0, v:GetMass() * 119.2, 0)
end
end
``````

I found another formula from the gravcomp chassis, a modified version of the A-Chassis that uses the realistic gravity preset (Which feels like the moon, hence 77 value from earlier), but I don’t really know how it works.

``````BodyForce.Force = Vector3.new(0, v:GetMass()*(workspace.Gravity-39.2), 0)
``````

This bit needs to be in parentheses (so that 119.2 is also multiplied by mass)

1 Like