Cant send gui message

Im struggling to load my game.
the error message i get is
menu/mainmenu.gui_script:8: Could not send message ‘start_game’ from ‘default:/menu#start’ to ‘loader:/go#loader’.
stack traceback:

Here is my code for my gui

function init(self)
	msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
	if(action_id == hash("touch") and action.released == true) then
		local textBegin = gui.get_node("start1")
		if(gui.pick_node(textBegin,action.x,action.y)) then
			msg.post("loader:/go#loader", "start_game")
		end
	end
	if(action_id == hash("touch") and action.released == true) then
		local textExit = gui.get_node("exit1")
		if(gui.pick_node(textExit,action.x,action.y)) then
			msg.post("@system:", "exit", {code = 0})
		end
	end
end```

here is my loader script

```lua
local function load_menu(self)
	msg.post("go#menu", "load")
	msg.post("go#menu", "enable")
end

local function unload_menu(self)
	msg.post("go#menu","unload")
end

local function load_main(self)
	msg.post("go#main", "load")
	msg.post("go#main", "enable")
end

function init(self)
	msg.post(".", "acquire_input_focus")
	load_menu(self)
end

function on_message(self, message_id, message, sender)
	if message_id == hash("start") then
		unload_menu(self)
		load_main(self)
	end
end

Can you please confirm that you have a collection with (not filename) “loader” and that it contains a game object with id “go” with a script component with if “loader”? Also confirm that the loader collection is your bootstrap collection (or loaded somehow)?

I have a loader collection with a loader game object with my loader script above and the main and mainmenu proxies and bootstrap is my menu screen. it builds and the menu comes up but the start button doesnt work

I found the Colorslide Tutorial really helpful to understand how to load collections via proxy.
You can find it here: https://github.com/defold/tutorial-colorslide
It is also available when you start a new project from the editor (“from tutorial” tab).


Take a look at the manual too: Collection proxy manual

There’s obviously something wrong in your setup since you are getting that error. Please study the example suggested by @anon95708182 . Also check this basic example:

1 Like