Question, How Would I Track The Player's Y Position And Put It In LeaderStats

Put this in a regular script inside ServerScriptService:

game:GetService("Players").PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Height = Instance.new("NumberValue")
	Height.Name = "Height"
	Height.Parent = leaderstats

	local char = player.CharacterAdded:Wait()
	
	while task.wait() do
		Height.Value = char:GetPivot().Position.Y
	end
end)

Setting the parent inside the parenthesis isn’t recommended, it should be set in a seperate line

This isnt my script, its actually @Orbular3 's script, combined with mine

Ok well you could change the script too. It’s recommended (for performance reasons) that you define the parent not only separate from Instance.new(), but in the last line.

local stuff = Instance.new("Part")
stuff.Name = "stuff"
stuff.Parent = workspace

Another thing: if you want your Y position to be more accurate, you can use char:GetPivot().Position which will return the position of the character’s model instead of just their HumanoidRootPart’s position.

I’m Just Saying The Code Char Seems to not work.

Can you try my script? I tested it in studio and it seems to work.

make sure the Script is in ServerScriptService, Make sure its a Server Script

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