So I'm making a game where you need to go as high as you can and for some reason the text label (which says how high is my HumanoidRootPart) and it just errors this:
Players.iMakeGames007.PlayerGui.ForHeight.HeightMeterz.LocalScript:5: attempt to index nil with 'Position'
while true do
local Player = game.Players.LocalPlayer
local Character = game:GetService("Workspace")[Player.Name]
local hrp = Character:FindFirstChild("HumanoidRootPart")
script.Parent.Text = "? "..hrp.Position.Vector3.yAxis
end
How can I fix this?

5 comments
Does it also work for a leaderstats script?
If you're talking about
WaitForChild, then yes.using the
while true doloop without wait() will crashbut if you use the
while true doloop USING wait() won't crashI haven't mentioned that because I consider using
while true dowithwaitaswhile wait() doinstead.