I am trying to make my game’s count go up every 5 seconds to every server. I already have MessagingService setup, now I just need a way to update data every 5 seconds without any errors.
For this it would be better to use tick() rather than counting on one server and updating to every other server, tick gives you the number of seconds elapsed since the unix epoch, you can just check if this number is near 5 using the modulus operator, so math.round(tick())%5==0, it is the same number for all servers.
But wouldn’t that count from the unix start and not when the data updates the first time?
Oh, I thought you meant you were trying to synchronize counting between servers, if you are sending data between servers every 5 seconds can’t you just use a while loop?
Here’s how the system works:
something tells server to update the counter → server gets the requests, and updates its own server → tells other servers to update & tells data to update, and this happens every 5 seconds.
Roblox would drop the data update request if I spam :SetAsync().
So the only thing being sent between servers is the time? In that case you should definitely use tick() if you need it to start counting at a certain point and count at exactly 5 second intervals after that point between all servers, then you can use messaging service to tell every other server to start counting, that way you only have to send 1 message per server.
I can’t use tick(), cause it would ALSO update when nobody is playing the game. I also don’t want to use it cause I want to make sure the script that tells server to update does it’s thing whenever the update takes place.
I’m confused, what is this timer for exactly?
It’s just a silly game my friend wants me to make, it’s just him biting a burger every 5 seconds.
Nevermind, me and my friend decided on the counter to be different in every server. Thanks for the help though!
So all servers have to have the biting take place at exactly the same time, with 5 second intervals, it sounds to me like the only way to do that is with tick(), even if you used a bunch of loops on different servers and started them all at once using messaging service they wouldn’t be perfectly synchronized and would veer off from eachother over time.
EDIT: Oh ok, have fun with your project!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.