# How can a BodyForce give the same gravity to all players?

1. What do i want to achieve? Basically i am trying to avoid gravity to players. I found the way to use BodyForce in humanoidrootpart

1. What is the issue? The problem is that it gives different gravity based on the player avatar (for example some player jump a bit, some players jump too much!)

2. What solutions have you tried so far? I searched online and i found that the issue can be the body mass and or dansity of the player character, but i don’t understand how to solve this problem and i don’t understand how to get mass or density of the character and how to modificate it.

How do i make sure that the players have the same gravity? If you have another method it is ok. All answers are welcome ;D!

You can get the Player’s mass by using `GetMass()` on every body part and then add them together. After adding them you can set the force of the BodyForce equal to the mass of the Player.

An example on how you could set this up is by first having a variable for the player’s mass. (`mass = 0`) Then use a for loop and search through any BaseParts that are in the character and use the `GetMass()` function and add it to the variable. (`mass += basePart:GetMass()`) After the loop is finished, simply set the force of the BodyForce equal to the variable. (`BodyVelocity.Force = mass`)

1 Like

I’m sry for the late answer, but i don’t understand a thing:

``````		local mass = 0

local bodyforce = Instance.new("BodyForce", char.HumanoidRootPart)

for	i,v in pairs(char:GetChildren()) do
if v:IsA("Part") then

mass += v:GetMass()

end

end

bodyforce.Force = Vector3.new(0,mass,0)
``````

But then how do i set the gravity that i want equal to all players? Bc now the force of the bodyforce is 0,2.8,0 (because of my mass). But the gravity i want is different to this

i solved with this script:

``````			local gravforceclone = game.ReplicatedStorage.GRAVFORCE:Clone()
gravforceclone.Parent = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")

local targetForce = 2016.892
local mass_default = 12.849721789360046
local jump_height = 1

local mass = 0
for _, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:IsA("BasePart") then
mass += v:GetMass()
end
end

local force = mass * targetForce * jump_height / mass_default
gravforceclone.Force = Vector3.new(0, force, 0)
``````

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.