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

How do I change this script that giving cash every second?

Asked by
R_oven 2
5 years ago

I got this Datastore2 script from AlvinBlox Youtube Video.

local DataStore2 = require(1936396537)



local defaultValue = 2000



game.Players.PlayerAdded:Connect(function(plr)

local cashDataStore = DataStore2("cash",plr)

local Stats = Instance.new("Folder",plr)

Stats.Name = "Stats"

local cash = Instance.new("IntValue",Stats)

cash.Name = "Cash"

local function cashUpdate(updatedValue)

cash.Value = cashDataStore:Get(updatedValue)

end

cashUpdate(defaultValue)

cashDataStore:OnUpdate(cashUpdate)

end)



game.Workspace:WaitForChild("Part").ClickDetector.MouseClick:Connect(function(player)

local cashDataStore = DataStore2("cash",player)

cashDataStore:Increment(400,defaultValue)



end)

and I want to change this part that give the 5 cash every 10 seconds. How do I change it?

game.Workspace:WaitForChild("Part").ClickDetector.MouseClick:Connect(function(player)

        local cashDataStore = DataStore2("cash",player)

        cashDataStore:Increment(400,defaultValue)



        end)
0
The code you posted shows that their cash increases every time they click the ClickDetector, not on a timer Shawnyg 4330 — 5y
0
I mean I want to change that part of the script into timer. R_oven 2 — 5y
0
Try removing the click detector and replace with a WhileLoop linked directly to each player. Then shove in a wait to create the time between money gain. master12712 5 — 5y

Answer this question