This is a Cash, KO, WO leaderboard
-- Start leaderboard game.Players.PlayerAdded:connect(function(player) -- Make leaderstats local leaderstats = Instance.new("IntValue", player) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = "Cash" money.Value = 100 local deaths = Instance.new("IntValue", leaderstats) deaths.Name = "Deaths" deaths.Value = 0 local kills = Instance.new("IntValue", leaderstats) kills.Name = "Kills" kills.Value = 0 -- Do stuff while true do money.Value = money.Value + 1 wait(1) end player.Character:WaitForChild("Humanoid").Died:connect(function() deaths.Value = deaths.Value + 1 end) end)
That while true do loop never exits, so the function beneath it is never reached and therefore never connected.
Just move the loop to the bottom of the function and you're fine. :P
As stated by adark, you should use a coroutine.
-- Start leaderboard game.Players.PlayerAdded:connect(function(player) -- Make leaderstats local leaderstats = Instance.new("IntValue", player) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = "Cash" money.Value = 100 local deaths = Instance.new("IntValue", leaderstats) deaths.Name = "Deaths" deaths.Value = 0 local kills = Instance.new("IntValue", leaderstats) kills.Name = "Kills" kills.Value = 0 -- Do stuff coroutine.resume(coroutine.create(function() while true do money.Value = money.Value + 1 wait(1) end end)) player.Character:WaitForChild("Humanoid").Died:connect(function() deaths.Value = deaths.Value + 1 end) end)
To learn more, read the wiki article: here.
-- Start leaderboard game.Players.PlayerAdded:connect(function(player) -- Make leaderstats local leaderstats = Instance.new("IntValue", player) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = "Cash" money.Value = 100 local deaths = Instance.new("IntValue", leaderstats) deaths.Name = "Deaths" deaths.Value = 0 local kills = Instance.new("IntValue", leaderstats) kills.Name = "Kills" kills.Value = 0 -- Do stuff while true do money.Value = money.Value + 1 wait(1) end local deadnow = player.Character:WaitForChild("Humanoid").Health if deadnow == 0 then deaths.Value = deaths.Value + 1 end) end)