This is my code I’d just be placing it at the beginning of my main script that runs after a player has loaded in (client sided) and then plays some screen effects:
Blockquote
if game:IsLoaded() then else game.Loaded:Wait() end
If this is a good method of yielding for game instances to be loaded before running intro GUI effects let me know. Otherwise I’d be open to other solutions.
This is a good method to ensure that the game is fully loaded before running any scripts that depend on game assets. However, it’s important to note that this will halt the execution of the script until the game is loaded, which may not be desirable in all cases.
If you want to run some code immediately and other code after the game is loaded, you can use a coroutine. Here’s an example:
-- Run this code immediately
print("Game is starting...")
-- Run this code after the game is loaded
coroutine.wrap(function()
game.Loaded:Wait()
print("Game is loaded.")
-- Run your intro GUI effects here
end)()
I could imagine having some code run immediately such as waiting for objects, maybe calling on services or requiring modules etc. at first and then having the effects play under the coroutine when the loading has been completed in a separate thread. Thanks!