Enabling Scripts and Message Passing

I’m trying to load one collection send a message to this collection and have a GUI disable. However, when I insert the message passing to the collection the GUI disable doesn’t work until I do it for a second time.

	elseif message_id == hash("start_track1") then
		--Loads track collection
		msg.post("#track1_proxy", "load")
		print('track1 collection loaded')
		--stops menu music
		sound.stop("#menuMusic")
		--Send message of car colour to track1 collection
		msg.post("Track1:/Main#Track1", self.carColour)
		print("car colour set")
		--Disables menu GUI
		msg.post("/Object#menu_gui", "disable")
		print('menu.gui script disabled')

The message “strack_track1” is received on a button press and the loading and disabling works when I comment out passing the message to track1 collection. Any help much appreciated.

When you send the load message to a proxy it takes a bit for the contents to actually load, so you can’t send messages into the new collection immediately. Once a proxy is ready it’ll send a proxy_loaded message back to you, meaning that everything’s ready and you can now send it messages!

2 Likes