Need a way to detect when 5 minutes have passed while keeping it synced across all servers

Currently, I have this code so far.

local rotationMinutes = 5 * 60

--math.ceil(os.time() / rotationMinutes)
-- seed changes every 5 minutes

I need a way when a new server is created, that the timer will be until the next seed change. I don’t want to use any long modules or datastores for this. I tried looking up how I would be able to sync this code efficiently, but found no results.

I made a way that uses data stores, but I figured there should be a way with some math to calculate each item and the time until the next item without datastores or https service.

I am using this for a shop that changes every 5 minutes, preferably without any long functions and just some math. If you are able to help that would be appreciated!

TLDR: I need some math to calculate how long until the next seed change

What’s the problem with your current approach of clamping the os.time? I see you commented it out, but that’s going to be how you’d want to do it.

1 Like

yeah, server os.time is the same for all servers, the code would be as simple as getting the time until the next 5 minute mark, which is simple, since the value could never be higher than 5.

use os.difftime os | Documentation - Roblox Creator Hub for it.

1 Like

I will try that, didn’t know that function existed.

The comment is the current code, there wasn’t a way to check how long from that code.

I tried using it but it returns -1, I found another way. Thanks for your help though

local rotationMinutes = 5 * 60

while task.wait(1) do
	local nextTime = math.ceil(os.time() / rotationMinutes)
	print(math.round((math.ceil(os.time() / rotationMinutes) - os.time() / rotationMinutes) * rotationMinutes))
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.