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

[ANSWERED] How to put the Y position of a player in the leaderboard?

As it is said in the tittle, I wanted to put the Y position of all the player in the leaderboard. To do that I have made this script :

 local function OnPlayerJoin(player)
 
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Height = Instance.new("IntValue")
	Height.Name = "Height"
	Height.Parent = leaderstats
	Height.Value = player.Character.Torso.Position.Y

end

game.Players.PlayerAdded:Connect(OnPlayerJoin)

I want to show the "altitude" of all players in the leaderboard by using the Y position of thier torso. My problem is that Character is a nil value The script is in ServerScriptService and it is a normal script

1 answer

I have found the problem! I needed to add repeat wait() until player.Character at the beginning of the function (and i needed to loop a part of the function so the value can change : while wait() do Height.Value = (player.Character.HumanoidRootPart.Position.Y - 8) end I hope I helped someone :P

2 comments

0

You can't change the Y value individually, it's view-only.

0

That's not what he's doing. He's reading it and assigning that value - 8 to his Height leader-stat.

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