This is my current code that's placed in ServerScriptService.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:connect(function()
		local hum = plr.Character:WaitForChild("Humanoid")
		local leaderstats = plr:FindFirstChild("leaderstats")
		local stat = leaderstats:FindFirstChild("Lives")
		if stat.Value == 1 then
			game.StarterGui.OneLifeLeft.OneLifePop.Visible = true
		end
	end)
end)

It works once the player's life count is at 1, but when the player dies and respawns with a new life count number (i.e. 5 lives), the pop up still appears even when the life count doesn't equal 1. Any help is greatly appreciated!

3 comments

0

Um, it never pops up... StarterGui is a replication container, it's assets are transferred to each connecting Client individually through their own folder's known as "PlayerGui". You must access this. You also don't disable it if it doesn't equal to one.

0

It doesn't seem you have an actual need for the Humanoid, so you can rid of your CharacterAdded callback.

0

Use GetPropertyChangedSignal on the Leaderstat, then set the visibility to the Boolean evaluation of "Lives.Value == 1"