So I want to make a cash system on the leaderboard which i got to work, but i want the cash to go up by 5 every 5 minutes if they buy the gamepass if they dont the cash rises by 1 every 10 minutes
I tried to script it it works fine in the studio Play Mode but in servers its not working..
wait (2) amount = 1 waiting = 10 id = 929780083 for i,v in pairs(game.Players:GetPlayers()) do if v then if game:GetService("MarketplaceService"):PlayerOwnsAsset(v, id) then v.PlayerGui.GuiMain.Enabled = true while true do wait(5) v.leaderstats["Bakery Bucks"].Value = v.leaderstats["Bakery Bucks"].Value + amount * 5 end else amount = 1 v.leaderstats["Bakery Bucks"].Value = v.leaderstats["Bakery Bucks"].Value + amount end end end
You should've added a while wait() do What a while wait() do loop does is that it waits for the amount of time you put on the wait() parameter (ex. wait(10)) so it'll wait 10 seconds then get the amount
wait (2) amount = 1 waiting = 10 id = 929780083 while wait(waiting)do for i,v in pairs(game.Players:GetPlayers()) do if v then if game:GetService("MarketplaceService"):PlayerOwnsAsset(v, id) then v.PlayerGui.GuiMain.Enabled = true while true do wait(5) v.leaderstats["Bakery Bucks"].Value = v.leaderstats["Bakery Bucks"].Value + amount * 5 end else amount = 1 v.leaderstats["Bakery Bucks"].Value = v.leaderstats["Bakery Bucks"].Value + amount end end end end
Hopefully this answered your question