How do i make a player leave a game when they die?
iv tried multiple things but none works, this is what I have so far but I cannot find where the player's health is so it wont trigger if they reset, Please help. Here is the script
function waitForChild(parent, childName)
local child = parent:findFirstChild(childName)
if child then return child end
while true do
child = parent.ChildAdded:wait()
if child.Name==childName then return child end
end
end
function onDied()
endgame:GetService("TeleportService"):Teleport(1520637787,game.Players.LocalPlayer)
end
Humanoid.Died:connect(onDied)
Please help if you know how