How to make a 3 Life System ❤️❤️❤️

I am in need of a 3 lives system, where if you die 3 times , you get kicked, it resets when you rejoin
However, I havent been able to find any tutorials on it, and I cannot script all of it myself
I cant find any solutions so far

any help is appreciated

1 Like

You could do either of these:

1.Each time the player died, count it [do it from the server].

2.Add an intvalue into each player when they join, and set it to 3[ or any amount you want them to start with]. Now, when they die, you could reduce from that value [-1], and make it also remove a heart or any image which representing a ‘life’.
An example:

local Players = game:GetService("Players")
local PlayersDeathCount = {}

Players.PlayerAdded:Connect(function(Player)
	PlayersDeathCount[Player.Name] = 0
	Player.CharacterAppearanceLoaded:Connect(function(Character)
		local Humanoid = Character.Humanoid or Character:WaitForChild("Humanoid")
		Humanoid.Died:Connect(function()
			PlayersDeathCount[Player.Name]  += 1
			if PlayersDeathCount[Player.Name] == 3 then
				Player:Kick("Died too many times")
			end	
		end)
	end)
end)
2 Likes

Put inside a ServerScript in ServerScriptService

game.Players.PlayerAdded:Connect(function(Player)
	local Lives = Instance.new("IntValue", Player)
	Lives.Name = "Lives"
	Lives.Value = 3
	
	Player.CharacterAdded:Connect(function(Character)
		
		if Lives.Value <= 0 then 
			Player:Kick("Ran out of lives!")
		end
		
		local Humanoid = Character:WaitForChild("Humanoid")
		
		Humanoid.Died:Connect(function()
			Lives.Value -= 1
		end)
		
	end)
end)
5 Likes

It works! Thanks so much

chars

Wait, but we can replace the kick thing with something else, right?

1 Like

yes you can replace it with anything you want