Confusion with game.loaded event

on the documentation for the game.loaded event it says “This event fires on the client when all initial Instances in the game have finished replicating to the client.
Unless they are parented to ReplicatedFirst, LocalScripts do not run until the game has loaded.” (DataModel | Documentation - Roblox Creator Hub).
but if you open a blank baseplate, put a screen gui inside startergui then try to access it from a local script inside of StarterPlayerScripts, when the game runs it will error saying the gui is not there because it hadn’t loaded in yet.
now what’s weird about this is that the same problem does not occur when the local script is placed inside of any of the other local script containers (StarterCharacterScripts, StarterPack, StarterGui).

in the documentation it just says “LocalScripts do not run until the game has loaded” and says nothing about this not being the case for local scripts specifically in StarterPlayerScripts.
is this a problem with the documentation or is this a bug or am i just missing something?

heres the code in the local script i used to access the gui in case it matters (though i did also try accessing it in other ways with the same result)

print(game.Players.LocalPlayer.PlayerGui.ScreenGui)

Instances placed in StarterGui are loaded when the player’s character is created, which happens after the datamodel has loaded.

1 Like

ok that would explain it. is this also the case for the StarterPack because i tried this same test with an instance in there and got the same result?

That’s right, When a new character is added, the current backpack is destroyed and everything in StarterPack is cloned into a new one.

ok thank you for clearing this up, one more question though, would a script placed in startergui be run before or after all the gui loads? also is there some page on the documentation that has all this information? i cant seem to find one.

StarterGui documentation
Backpack documentation
I can say from experience that yes, all guis will be loaded when scripts begin to run under StarterGui.

1 Like

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