I’m trying to make it so that the player jumps in the air with a force then it gets deleted after so it cancels.
But, when some of my friends try the game, sometimes they don’t get pushed up and jump up very little. Sometimes they get jumped higher than usual. Why is body force so unreliable, is it just because it is unreliable or because the player is laggy or im doing something wrong? I want it to go up a normal amount and thats all, if there are alternatives you can tell me too.
You should have looked into the API reference next time:
Apparently, we have some mix-up with the body movers. We’re not quite certain why the force is affects players differently but its mass difference due to accessories.
According to the BodyForce example, the player’s jump height is affected by two factors:
Acceleration
Mass
…which is Newton’s second law of motion, describing force.
The acceleration depends on the workspace.Gravity. The most important factor that varies between players is the mass. The mass is different for each player’s size but also sometimes accessories and the tools they are holding.
For each character, you need to get the total mass. This function would help getting the total mass, since each character are models.
local function getMassFromModel(model)
local mass = 0
for _, object in pairs(model:GetDescendants()) do
if object:IsA("BasePart") then
mass += object:GetMass
end
end
return mass
end
After that, remember Newton’s second law of motion: Multiply the mass with the workspace’s gravity and then multiply it again with an alpha with an interval between 0 to 1, depending on how much of gravity you want to negate. 0 for nothing and 1 for total anti-gravity.
local function getMassFromModel(model)
local mass = 0
for _, object in pairs(model:GetDescendants()) do
if object:IsA("BasePart") then
mass += object:GetMass
end
end
return mass
end
local bodyforce = Instance.new("BodyForce")
bodyforce.Force = getMassFromModel