How will i make a script that auto payouts a certain amount of time

I have an NPC and when you walk up to it you can collect your daily check.
Now how would I make it so that when you collect it you have to wait another like 10 minutes to go back?

Thanks

Try using os.time() for it, and some datastores, and just check if time has come.
For example:

-- Put the code in input event that you use. Example: ProximityPrompt, ClickDetector e.t.c

local LastTime = DataStore:GetAsync(Player.UserId);
local NowTime = os.time();

if NowTime then
   if NowTime - LastTime < 600 then -- if difference is in between 10 minutes
      -- Payout here and store LastTime value.
   end;
else
   -- Payout here and store LastTime value.
end;
1 Like