Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

How can i kick a player when they die?

Asked by 4 years ago

i am trying to kick a player out of the server when he/she 's HP = 0 ,so they can't respawn anymore...

1
Please accept an answer EnzoTDZ_YT 275 — 4y

2 answers

Log in to vote
3
Answered by 4 years ago
Edited 4 years ago

Upon the players death this will kick them

--//  Author: EnzoTDZ_YT
--//  File: PlayerDiedKick.lua

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character.Humanoid.Died:Connect(function(Death)
            Player:Kick("You Died")
        end)
    end)
end)

Put in serverscriptservice as a regular script btw didnt know people already answered i had this page open with no answers sorry if it looks like i copied.

0
As my answer works please accept EnzoTDZ_YT 275 — 4y
Ad
Log in to vote
1
Answered by
karlo_tr10 1233 Moderation Voter
4 years ago

Keep in mind that this is not request site but as this is very simple I will make it for you:

This should be in normal script placed in ServerScriptService(best choice) or Workspace

game.Players.PlayerAdded:Connect(function(Player) -- Detects when a player joins
    Player.CharacterAdded:Connect(function(Character) -- Detects when his character is addded
        Character:WaitForChild("Humanoid").Died:Connect(function() -- And when he died it will kick him
            Player:Kick("You died!")
        end)
    end)
end)

Answer this question