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
game:GetService('Players').PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        character:WaitForChild("Humanoid").Died:Connect(function()
            print(player.Name .. " has died!")
            local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
            Player:kick("You died!")
        end)
    end)
end)

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:

Lastmsg = "(You died)" 
How = 1 
game.Players.PlayerAdded:connect(function (p)
    local Num = Instance.new("IntValue", p)
    Num.Name = ("Deaths")
    p.CharacterAdded:connect(function (c)
        c.Humanoid.Died:connect(function()
        Num.Value = Num.Value + 1
        local Value = Num.Value
        if (Value == How) then
            wait(1)
            local PlayName = p.Name
        local msg = Instance.new("Hint", game.Workspace)
            msg.Text = (PlayName.." Has died, You can only live once.. As known as "..Lastmsg)
            wait(5)
            msg:remove()
            p:remove()
            wait()
        end

    end)
end)
end)

Ad

Answer this question