What would be the best way to award money every X amount fo minutes?
Would I just create a loop on player join?
Wondering for the best way to save resources, etc.
What would be the best way to award money every X amount fo minutes?
Would I just create a loop on player join?
Wondering for the best way to save resources, etc.
You could use os.time
or just use a while loop and award it after certain intervals. Also use SetAsync
after giving them money.
local minutes = 5
game:GetService("Players").PlayerAdded:connect(function(player)
while wait(minutes * 60) do
-- reward player
end
end)
That should do the job
This is an example using os.time
, same concept though.
game:GetService("Players").PlayerAdded:Connect(function(player)
while true do
local passed = os.time()
repeat wait(1) until (os.time() - passed) >= interval
player.leaderstats.Money.Value += amount
end
end)
What one would be more efficient to do?
I’m not exactly sure I just know of 2 ways to do it lol
I’ll stick to using while wait(10) do
seems like it would be better to do as I would only be doing 1 wait.
Adding on to this, if i was to check for a gamepass for X2 money would I be best just setting a BoolValue on the player server-side or just checking everytime.
Make each player have a multiplier IntValue and multiply the money earned by that IntValue.