Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to find/change character distance from the ground? [Solved]

I recently learned that character legs can collide, so what is it exactly determining how far a player model is from the ground, and how can I access this property? I found this out after disproportionately scaling player models, and I found that the legs were floating from the ground.

2 answers

Well to change it might be hard but here is how to detect how far it is from it, so first we are gonna be using Magnitude, magnitude is a term used across mathematics that means several things. In vector theory, the magnitude of a vector is the length of a vector, im not gonna go into depth on how it works, you want to learn more about it go here. So to get the magnitude between 2 parts you have to do

part1 = game.Workspace.Part1
part2 = game.Workspace.Part2

local Magnitude = (part1 - part2).magnitude
print(Magnitude)

but to always get it you can use a While Loop, to do so you want to add this small line of code

part1 = game.Workspace.Part1
part2 = game.Workspace.Part2

while wait() do
local Magnitude = (part1 - part2).magnitude
print(Magnitude)
end

so now that you know about how to get magnitude we can get the players distance between them, so this line of code should detect it

game.Players.PlayerAdded:connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local ground = game.Workspace.Baseplate
while wait() do	
	 if character then
		local torso = character.Torso
		 if torso then
			local Magnitude = (torso.Position - ground.Position).magnitude
			if Magnitude > 172 then 
				print("Player is off of the ground")
				print(Magnitude)
			end
		end
	end
end	
end)

I hope this helped you!

1 comment

0

Wow thanks! I don't have the rep to upvote but when I do I'll come back to upvote this.

This discussion is preserved as it was. New answers, comments, and votes are closed.