I have a GUI that shows the players current altitude, it works fine apart from when the player dies, the displayed number is stuck at whatever it was when the player died. here is the script: (local script located within the TextLabel in StarterGui)
local plr=game.Players.LocalPlayer
local label=script.Parent
local head=plr.Character:WaitForChild("Head")
while true do
local height=head.Position.Y
local roundheight = math.round(height)
label.Text=roundheight-4
wait(0.1)
end
You will need to redefine the character and hence the head every time the player joins. one way you can do this is as such:
local plr=game.Players.LocalPlayer
local label=script.Parent
local head
local function GetHead()
head = (plr.Character or plr.CharacterAdded:Wait()):WaitForChild("Head")
head.Destroying:Once(GetHead)
end
GetHead()
while true do
height=head.Position.Y
roundheight = math.round(height)
label.Text=roundheight-4
wait(0.1)
end
It basically just redefines the head variable whenever the previous head is destroyed