Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

1 comment

0

Please use code blocks!

1 answer

✓ Accepted answer

This will kick the player when he died

 game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
	player:Kick("Change this") -- Change this to the kick message.
end)
end)
	
end)

1 comment

0

Thanks :)

This discussion is preserved as it was. New answers, comments, and votes are closed.