Loading Screen script fires the bindable event before the listeners are ready , causing it to not work

Hello everyone

I have a script that is responsible for the loading screen gui and when the player Press start they fire a bindable event to the other script responsible for linking the gui to a Button.Activated event. However, the script responsible for the loading screen is in the Replicated First meanwhile the script that receives the bindable event is inside player scripts. and the player’s character doesn’t spawn until the player press Start which means the second script doesn’t load until the character is spawned making the bindable event fire at nothing (as the listeners have not been set yet).

to shorten this, is there a way to make sure that the script is loaded before firing the event?

Did you try waiting for the scripts e.g. WaitForChild("whatever")?

well the problem is I have a few WaitForChild() inside the second script (the one inside the player scripts) which delay setting up the listeners a bit

No, I mean that you have the option in the main script (the loading screen controller) to check whether all scripts (listeners) exist using this method.

1 Like

hmmm I will try this one out

Char limit

Another option would be to create a global variable, such as _G.Loaded = true . This would save you the need to create a bindable event to tell other scripts that the loading screen is finished.

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