I'm attempting to make a character float. Here is my script


function getMass(model)
	local weight = 0
	if model:IsA("BasePart") then
		return model:GetMass()
	end
	if #model:GetChildren()>0 then
		for _,v in pairs(model:GetChildren()) do
			weight = weight + getMass(v)
		end
	end
	return weight
end


game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character) 
	local character=player.CharacterAppearanceLoaded:Wait()
	local mass = getMass(character)
	local force = Instance.new("BodyForce",character.LowerTorso)
	force.force = Vector3.new(0,196.2*getMass(character),0)
	end)
end)


I'm adding a force in the lower torso equal to 196.2 * the total mass of the character including hats etc. It seems that's too much and the character is rising. I have no idea why.

3 comments

0

your Force.Y ?

0

Ends up being 5386.631 which is apparently too much for the weight. This means it's calculating the weight to be 27 or so which I guess is too much?

0

small tip: idk why you would change this value but you should use workspace.Gravity instead of 192.6