Hey I'm trying to make a leaderboard for deaths and my script doesn't really seem to track deaths and it's not showing any errors. I have two scripts, one for creating the leaderboard and one for tracking deaths. Here's my scripts, if possible could you explain what I did wrong? Thanks! Creating leaderboard script:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Deaths = Instance.new("IntValue",leaderstats)
Deaths.Name = "Deaths"
Deaths.Value = 0
end)
Tracking deaths script:
local function playerDead(player)
local Deaths = player:WaitForChild("leaderstats").Deaths
local hum = player.Parent:FindFirstChild("Humanoid")
if hum then
if hum.Health == 0 then
Deaths.Value = Deaths.Value + 1
end
end
end
game.Players.PlayerAdded:Connect(playerDead)

7 comments
Ah you are 49 seconds faster. :)
Thank you so much for the help! Also, can you explain the GetService thing? When would you use that?
Oh, yeah. One of the good things about being a scripter is that you can type fast.
GetService("Players") is basically the same thing as game.Players. It's a good habit to use GetService() almost all the time since it checks if a service is existent. If it isn't it creates that service.
For more information, go here: https://developer.roblox.com/en-us/api-reference/function/ServiceProvider/GetService
Wow, you're an amazing scripter! Thanks bro
No problem.