I’ve put together a tutorial on creating a global weather system in Roblox using GlobalStockService, This system allows you to switch between Rain, Fog, and clear skies
The tutorial is uncopylocked, so you can see all the scripts and follow along step by step, It’s a great way to learn how to make immersive, dynamic weather in your Roblox games!
I will presume they were using it for a chance-based system, don’t really see the need of using this module as there are much easier and simpler approaches.
GlobalStockService is basically a utility module that manages weighted random “stocks” of items that refresh on an interval
Think of it as a way to simulate a “market” of items/events where:
You define items with a chance/weight
The service “restocks” after a given amount of time
Other scripts can check what’s currently in stock, or listen for changes when the stock updates
In the context of the WeatherHandler, I’m using it so that the weather changes globally and consistently across all servers, without needing an external centralized server, Instead of each server rolling its own random weather, GlobalStockService keeps everything in sync automatically, though there might be a latency between servers before they all update
From a quick look into the code of GlobalStockService, it seems like you are using pseudo random generation, and the stock/weather is determined by that pseudo random number generator, but it still uses datastores to change the seed? Is that right?
From your Resources > Community Resources thread on GlobalStockService, I though it was creating stock and sharing it to every server (having 1 server act as the central “database”), but looking at the code, it seems to use Datastores and MemoryStores very sparingly, which I like. Pseudo random number generation is very powerful
GlobalStockService uses a deterministic pseudo-random generator to compute stock, based on a global key combined with a restock anchor timestamp, The key itself is stored in the DataStore so it’s shared across servers, but the actual stock generation doesn’t rely heavily on datastore calls, it’s calculated locally using the pseudo-random generator
We also use MemoryStoreService to handle “forced” stock that overrides normal generation, which is why you see only minimal calls there, So essentially, one global key acts like a seed for all servers, but stock is generated locally without constant datastore traffic
is there a way to make it sync across subplaces? as i want to have the same weather that lobby has when teleporting to game, i was thinking datastore but that would lag.