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

Does anyone know how to make it that if you die, you are kicked from the game?

Asked by 4 years ago
1game:GetService('Players').PlayerAdded:Connect(function(player)
2    player.CharacterAdded:Connect(function(character)
3        character:WaitForChild("Humanoid").Died:Connect(function()
4            print(player.Name .. " has died!")
5            local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
6            Player:kick("You died!")
7        end)
8    end)
9end)

I made this script to detect when you die, then kick you but its not working, can i get help?

0
you can delete line 4 all it does is prints the player has died LTRNightmare 66 — 4y

1 answer

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

Try:

01Lastmsg = "(You died)"
02How = 1
03game.Players.PlayerAdded:connect(function (p)
04    local Num = Instance.new("IntValue", p)
05    Num.Name = ("Deaths")
06    p.CharacterAdded:connect(function (c)
07        c.Humanoid.Died:connect(function()
08        Num.Value = Num.Value + 1
09        local Value = Num.Value
10        if (Value == How) then
11            wait(1)
12            local PlayName = p.Name
13        local msg = Instance.new("Hint", game.Workspace)
14            msg.Text = (PlayName.." Has died, You can only live once.. As known as "..Lastmsg)
15            wait(5)
View all 23 lines...
Ad

Answer this question