Yield all/certain scripts until data loads?

Is there a way to yield a script until a dataStore loads? I don’t just want to add a task.wait() to every script

Use module scripts instead of regular scripts. Then have your script that loads the datastore require all the modules when the datastore is loaded.

1 Like

Isolate your data persistence system into a module that is bootstrapped. Provide a function for accessing the cached downloaded data. In that function, add a yielding mechanism that pauses the caller thread until the data is available. Throughout your codebase, only access data through that function

1 Like

So, you’re saying that I don’t need to make all of my scripts a ModuleScript and require them, but instead just make a function that gets the data, can you show an example maybe?

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