Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cash every 60 seconds script?

Asked by 5 years ago

I need a script that gives cash every 60 seconds preferably 5. Here is my leader board script

CashData = game:GetService("DataStoreService"):GetDataStore("CashData")
GemsData = game:GetService("DataStoreService"):GetDataStore("GemsData")

game.Players.PlayerAdded:connect(function(plr)
    local stats = Instance.new('IntValue', plr)
    stats.Name = 'leaderstats'
    local cash = Instance.new('IntValue', stats)
    cash.Name = 'Cash'
    cash.Value = 0

    stats.Name = 'leaderstats'
    local cash = Instance.new('IntValue', stats)
    cash.Name = 'Gems'
    cash.Value = 0
end)

Please help me a could not find a way!

1 answer

Log in to vote
0
Answered by 5 years ago

Here's a simple script...

local interval = 60
spawn(function()
    while true do
        for i,v in pairs(game.Players:GetPlayers())do
            v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + 5
        end
        wait(interval)
    end
end)
0
Would recommend adding checks..such as, checking if the player actually has leaderstats before you go to change their cash ForeverBrown 356 — 5y
Ad

Answer this question