Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to count a value when the player is not playing game?

In my game, I am adding a group rewards system, that gives you 200 cash every 4 hours, but if the player leaves the game the 4 hour countdown stops and when they join again allows them to get the reward. If I use datastores it saves the value when the player leaves, when they join again it goes to the value saved instead of to have been counting.

Is there a way to keep counting if the player is offline or not playing the game?

1 answer

✓ Accepted answer

The widely adopted and best way to have a countdown continue while a player is offline is to store when the player logged off, and then when they log on, calculate what they should get by comparing when they logged off to now. In your case you would check how many 4 hours have passed and the current state of the 4 hour countdown.

1 comment

0

just use os.time save there log off time then when they come back the new os.time will be the present and the other time will be the pass and when they get the award reset the datastore to the time that they collected it at

This discussion is preserved as it was. New answers, comments, and votes are closed.