I want to make a timer for a daily reward system, in which it says the amount of time i need to wait to reclaim the reward, but I don’t know how to make a timer once claimed. I’ve tried researching things on os but none of it has seemed to help me. The point is in, I can’t make the timer because don’t know where to start. Thanks for the help
You could use tick()
and save that a data store, then load it later and subtract it from the current tick()
to see how many seconds has passed and if a certain amount of seconds passed, reward something and reset the data store with a new tick()
In a datastore, store a value which is os.time() with any key in a table in your datastore. Whenever the player joins, do something like:
local playersLastTime = playersData.LastRewardTime
if os.time() - playersLastTime >= 86400 then
– give daily reward and set playersData.LastRewardTime back to os.time() again
end