Hello! I am trying to make a leaderboard that incorporates Kills/Deaths & Cash
The Cash stat is designed to give players Cash every 5 seconds they are in the server.
After some tweaking, I have my Kills & Deaths working, But Cash does not add anything. I know it is calculating because if I grab coins within the game, They add to the total, It just doesn't add increments.
I am not an expert coder, But I know I have something in the wrong spot.
Please help!
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent= plr
local kills = Instance.new("IntValue")
kills.Name = "Kills"
kills.Parent = stats
local deaths = Instance.new("IntValue")
deaths.Name = "Deaths"
deaths.Parent = stats
local score = Instance.new("IntValue")
score.Name = "Cash"
score.Parent = stats
score.Value = 1
plr.CharacterAdded:Connect(function(char)
local humanoid
repeat
humanoid = char:FindFirstChild("Humanoid")
wait()
until humanoid
humanoid.Died:Connect(function()
deaths.Value = deaths.Value + 1
local tag = humanoid:FindFirstChild("creator")
if tag then
local killer = tag.Value
if killer then
killer.leaderstats.Kills.Value = killer.leaderstats.Kills.Value + 1
while true do
wait(5)
score.Value = score.Value + 5
end
end
end
end)
end)
end)

2 comments
Daily reward designed in cash?
Not a daily reward, Just an incremental system. The longer you stay in the game, the more cash you get.