So I’m wondering about handling the task of making a Daily Rewards System, I already understand the usage of os.time() or os.date() to make this system, but I was wondering on how to check the dates and if the Time the Player has joined is within the next consecutive day, but if they miss that day, the Data will reset? I’m not asking for a script, I’m merely asking for an explanation like what numbers to use for this?
So you reward them for playing that day, the next day comes while they’re still in-game, because the code only checked when they joined whether or not to reward them, it doesn’t trigger and they don’t get rewarded.
I would say you need an event to trigger when the next day occurs and reward those who are in-game.
Honestly don’t know how good this would be cause I just thought of something different but it could be good.
When the play joins the game, or when they claim the reward, check the time using the code fragment marked as solution, then you can just spawn wait the difference between the two times before updating the thing (you would probably want to do that on the client), once the wait is over fire a remote event (confirm it’s actually over and an exploiter didn’t just fire it) then allow the player to collect again
I only have a question, wouldn’t thsi make the player have to join in less than 24 hours? That wouldn’t work theoretically, because the player would have to join befor 24 hours, I think instead you would need to check 48 hours, as that’s the end of the second day, and that’s when you want to not reward the player, so the number should be:
172800, and the script:
local Now = os.time()
local Data = 0
if Now - Data >= 172800 then
-- cancel
end
It’s a daily reward, they should be claimed after 1 day, 24 hours, or 86400 seconds. I don’t get why you are trying to make the daily reward system a 2 day (48 hour) cooldown
No, he wants taht after the 24 hours you are able to claim the reward, for taht the number is right, but he also wanted that if you dot. Get the reward in time, it eliminates itself, which for that would be 48 hours after you got the last reward
Aha, I get what you’re saying now but instead of hardcoding it you should multiply the 86400 by the number of missed days and check the last claimed time against that
Just so you know, I wasnt asking how to Handle a Daily Rewards system as I already how to to do it, I was asking what number should I be using to check when to cancel their streak, because the results vary.
The only reason I gave the other person the Solution is because it had that.