I need to sync the weathers on each island individually across all servers. Some Islands could be snowing, or raining, or just normal. How can I achieve this?
I’ve tried using MessagingService, but when a new server starts up I don’t know how to get the information that I’ve been transferring to each server.
This doesn’t sound like a bad idea. I just don’t know if it will work 100%, because what if all servers fire PublishAsync at once, and the datastore saves them all? Some servers may be different than other ones in that case.
To get the same weather across all servers you need to use os.time().
local currentWeather = "Clear"
local weatherTimes = {
Rain = 200,
Snow = 600,
Clear = 900,
}
local maxTime = 1400
while true do
local currentTime = os.time()%maxTime
local bestMatch
for weather, t in pairs(weatherTimes) do
if t > currentTime then
bestTime = t
bestMatch = weather
end
currentWeather = bestMatch or 'not work'
print("It's "..currentWeather.."ing!")
task.wait(300) --5 minutes
end