I have a game that goes down to FallenPartsDestroyHeight but when that happens, it deletes my character, causing this script to cause an error:
wait(0.5)
while true do
for i, player in ipairs(game.Players:GetPlayers()) do
if player.Character then
player.leaderstats.Altitude.Value = player.Character.UpperTorso.Position.Y
end
end
end
wait()
end
i've tried
if not player.Character.UpperTorso.Position.Y <3 -40000 then
and
if player.character.UpperTorso == nil
but they don't seem to work(maybe I just got them wrong...)
Edit: This works!
if player.Character:FindFirstChild("UpperTorso") then
player.leaderstats.Altitude.Value = player.Character.UpperTorso.Position.Y
end

5 comments
Have you tried workspace.ChildRemoved?
no, I'll try it now
Because ChildRemoved returns the child being removed as an argument, you can connect the event to a function with an argument named child.
The problem is that as soon as the players charter is deleted, it fires up the error. How can I fix that?
Oh! I fixed it! Can you answer so I can accept your answer!