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

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

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?

1 comment

0

you can delete line 4 all it does is prints the player has died

1 answer

✓ Accepted answer

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)

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