1 | game: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 ) |
9 | end ) |
I made this script to detect when you die, then kick you but its not working, can i get help?
Try:
01 | Lastmsg = "(You died)" |
02 | How = 1 |
03 | game.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 ) |