Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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

0
You can't change the Y value individually, it's view-only. DeceptiveCaster 3761 — 5y
0
That's not what he's doing. He's reading it and assigning that value - 8 to his Height leader-stat. BlueGrovyle 278 — 5y
Ad

Answer this question