I have this death detector that helps with subtracting a life each time a player dies. The problem is that the leaderboard is not updating after the player dies, but the variable does update.
LocalScript in StarterChararacterScripts:
local player = game.Players.LocalPlayer
local character = player.Character
character:WaitForChild("Humanoid").Died:Connect(function()
local lives = player.leaderstats.Lives.Value
lives = lives - 1
print("lives: " .. lives) -- prints out "2"
end)
Script in ServerScriptService:
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local lives = Instance.new("IntValue")
lives.Name = "Lives"
lives.Parent = leaderstats
lives.Value = 3
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
OUTPUT:
13:32:43.435 - lives: 2
But on the leaderboard in-game, it still displays I have 3 lives left.