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

Does anyone have a code for a script that gives you cash every second?

Asked by 9 years ago

I have tried to come up with one but when ever I try one it never works! Can anyone please help me with this. I have tried this script that I made but did not work.

game.Players.PlayerAdded:connect(function(plr)  
    pcall(function() coroutine.resume(coroutine.create(function()     
        while true do      
            wait(60)      
            plr.leaderstats.cash.Value = plr.leaderstats.cash.Value + 100      
        end))    
    end)    
end)

1 answer

Log in to vote
0
Answered by 9 years ago
game.Players.PlayerAdded:connect(function(Player)

    local leaderstats = Instance.new("Folder", Player) -- Instance.new(ClassName, Parent)
    leaderstats.Name = "leaderstats"

    local Cash = Instance.new("IntValue", leaderstats)
    Cash.Name = "Cash"
    Cash.Value = 0 -- Starting Cash Value

    spawn(function()

        local Amount = 1 -- Set this to the amount you want generated every second

        while wait(1) do -- looping every second
            Cash.Value = Cash.Value + Amount -- now adding
        end

    end)

end)
0
thank you so much! :) taylorjames112 0 — 9y
Ad

Answer this question