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
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