[UPDATED]
I have 2 scripts in my project : one is making a maze, and the other is modifying some aspect of the maze and more.
I will call the script making the maze “script 1” and the other modifying it “script 2”
The script 1 need to tell script 2 when the maze is ready to be modify. I use for this a bindable event which is fired by script 1 and received by script 2.
The problem is : they load and execute following a random order. This is a problem because sometimes, the script 1 load and finish building the maze, then try to inform the script 2 by firing the bindable event. However, script 2 hasn’t loaded yet and connected the event to the function which allow him to continue the job by modifying the maze. This result in the script 2 not modifying anything of the maze.
I’m trying to make the script 1 wait for the script 2 to be ready before firing the event.
I want to know how can I achieve this goal.
I also want to know if I can wait for all the script and modules operated by the server to wait until all of them are loaded and ready to execute to avoid in the future this type of problems.
A more graphic explanation of how my scripts works
local MazeReadyEvent = --The bindable event
--script 1
--script to build the maze...
MazeReadyEvent:Fire()
--script 2
local function ModifyMaze()
--script to modify the maze
end
MazeReadyEvent.Event:Connect(ModifyMaze)