Messaging a gui before it's laoded

I’ve got a problem where i’m passing a message and loading a gui from the loader script in the same function resulting in both things being executed in the same frame. This has resulted in the gui being messaged before the gui has been enabled/loaded. Does anyone know how i can message the gui after it has been loaded.

This code below both recieves the message which will be passed to the gui and also passes a message to the loader script to call for the gui to be loaded:

	if message_id == hash("game_complete") then
		self.timer = message[timer]
		unload_game(self)
		load_level_complete(self)
	end

At the moment this function both loads and sends the message to the gui

local function load_level_complete(self)
	msg.post("go#level_complete", "load")
	msg.post("go#level_complete", "enable")
	msg.post("level_completed:/level_completed#level_completed", "time", {timer = self.timer})
end

How can i split the message from the line that gets the gui to load so that the gui can recieve the message after it has loaded

That doesn’t work. Sending a message is asynchronous, and loading a collection is also synchronous. You can’t do anything with a loaded collection until you receive a “proxy_loaded” message. This means that you have to deal with this in stages. First you load and wait for proxy_loaded, then you enable, and then in the next frame you can send a message.

Have a look at this example: