I want to have 2 leaderboards in my Roblox game. One which shows In-Game time (in seconds) and the second one which shows the number of deaths after clicking the join button.
I found 2 tutorials on youtube. Both of them work but when I enable the Number of deaths script, the In-Game Time script doesn't work.
This is the In-Game Time script I use:
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local secs = Instance.new("IntValue")
secs.Name = "Time"
secs.Value = 0
secs.Parent = stats
stats.Parent = newPlayer
while true do
wait(1)
secs.Value = secs.Value + 1
end
end
game.Players.ChildAdded:connect(onPlayerEntered)
And this is the Number of deaths script I use:
game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
print(player.Name .. " has died!")
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1
end)
end)
end)
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
end)
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model", player)
leaderstats.Name = "leaderstats"
local score = Instance.new("IntValue", leaderstats)
score.Name = "Deaths"
score.Value = 0
end)
Of course, I don't need to use any of these scripts, they can be changed.
I'm not a good scripter and I need help. Thank you in advance. :)

2 comments
See my edited script it will start deaths at 0
And it will not show the error