Text value won't update

I am trying to make a kills/deaths leaderboard and when I die, a value changes and it shows how many times I have died in game. When I die the first time, it works. Once I die the second time, nothing happens?

Server script:

game.Players.PlayerAdded:Connect(function(player)
	local Character = player.Character or player.CharacterAdded:Wait()
	Character.Humanoid.Died:Connect(function()
		game.ReplicatedStorage.UpdateDeaths:FireAllClients(player)
	end)
end)

Local script:

local Player = game.Players.LocalPlayer
local Players = game:GetService("Players")
local Leaderboard = Player.PlayerGui:WaitForChild("Leaderboard")
local Team1 = Leaderboard.Frame:FindFirstChild("Team1")
local Team2 = Leaderboard.Frame:FindFirstChild("Team2")
local List1 = Team1:FindFirstChild("List")
local List2 = Team2:FindFirstChild("List")

game.ReplicatedStorage.UpdateDeaths.OnClientEvent:Connect(function(plrName)
	if List1:FindFirstChild(plrName.Name) then
		List1:FindFirstChild(plrName.Name).Deaths.DeathsValue.Value += 1
		List1:FindFirstChild(plrName.Name).Deaths.Text = List1:FindFirstChild(plrName.Name).Deaths.DeathsValue.Value
		print("Updated value")
	elseif List2:FindFirstChild(plrName.Name) then
		List2:FindFirstChild(plrName.Name).Deaths.DeathsValue.Value += 1
		List2:FindFirstChild(plrName.Name).Deaths.Text = List2:FindFirstChild(plrName.Name).Deaths.DeathsValue.Value
		print("Updated value2")
	end
end)

Anybody know why?

The server doesn’t detect the subsequent additions of characters. Consider adding a CharacterAdded event.

Character is only defined once in your example, and that’s only when they initially spawn the first time.

When I do this, now nothing happens at all.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		game.ReplicatedStorage.UpdateDeaths:FireAllClients(player)
	end)
end)

Is the client still receiving events properly?

Oh yeah. Nevermind. It works. Thanks!

1 Like
local players = game:GetService("Players")
local replicated = game:GetService("ReplicatedStorage")
local updateDeaths = replicated.UpdateDeaths

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid.Died:Connect(function()
			updateDeaths:FireAllClients(player)
		end)
	end)
end)