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?