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

How do i make a currency system involving gamepasses?

Asked by 7 years ago

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
0
Keep in mind, the code will only run once. FiredDusk 1466 — 7y

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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

Ad
Log in to vote
0
Answered by 7 years ago

Thank you

Answer this question