# Could not send message 'casual\_game' from 'loader:/go#loader' to 'main:/factories#startgame' (solved)

**URL:** <https://forum.defold.com/t/could-not-send-message-casual-game-from-loader-go-loader-to-main-factories-startgame-solved/74712>\
**Category:** Questions\
**Created:** [October 28, 2023, 4:21am UTC](https://forum.defold.com/t/could-not-send-message-casual-game-from-loader-go-loader-to-main-factories-startgame-solved/74712 "2023-10-28T04:21:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![schlista](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/schlista/32/33758_2.png) [@schlista](https://forum.defold.com/u/schlista)\
**Post date:** [October 28, 2023, 4:21am UTC](https://forum.defold.com/t/could-not-send-message-casual-game-from-loader-go-loader-to-main-factories-startgame-solved/74712/1 "2023-10-28T04:21:09Z")

</div>

Can someone help me know why this isn’t working?

I have a loader (aka controller) that loads my main collection when the user selects the play button. I’m Trying to also send a message to the main telling the main collection what mode to play. I guess I can create 3 different collection of game modes, but it’s so much smaller code if I just capture the few minor differences in the main collection. So anyway I get this error:

Could not send message ‘casual\_game’ from ‘loader:/go#loader’ to ‘main:/factories#startgame’.

I’ve done a print(msg.url()) and confirmed it’s the correct full URL from the loader to the startgame script.

this is my loader script:

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

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

local function load_main(self)
	msg.post("go#main", "load")
	msg.post("go#main", "enable")
	msg.post("main:/factories#startgame", hash("casual_game"))
end

local function unload_main(self)
	msg.post("go#main", "unload")
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_casual") then
		unload_menu(self)
		load_main(self)
	elseif message_id == hash("goto_menu") then
		unload_main(self)
		load_menu(self)
	end
end

```

Any suggestions are very much welcomed.

---

<div class="post-metadata">

**Author:** ![schlista](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/schlista/32/33758_2.png) [@schlista](https://forum.defold.com/u/schlista)\
**Post date:** [October 28, 2023, 4:28am UTC](https://forum.defold.com/t/could-not-send-message-casual-game-from-loader-go-loader-to-main-factories-startgame-solved/74712/2 "2023-10-28T04:28:28Z")

</div>

Already solved it. I had to wait for the proxy to load the collection.

```lua
if message_id == hash("proxy_loaded") then
		if game_mode == "casual" then
			msg.post("main:/factories#startgame", hash("casual_game"))
		end
	end

```

[Collection proxy manual (defold.com)](https://defold.com/manuals/collection-proxy/#collection-proxy)

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [October 28, 2023, 6:11am UTC](https://forum.defold.com/t/could-not-send-message-casual-game-from-loader-go-loader-to-main-factories-startgame-solved/74712/3 "2023-10-28T06:11:59Z")

</div>

Good that you solved it.

Also, please assign a category for your posts 🙂

---

<div class="post-metadata">

**Author:** ![schlista](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/schlista/32/33758_2.png) [@schlista](https://forum.defold.com/u/schlista)\
**Post date:** [October 28, 2023, 4:16pm UTC](https://forum.defold.com/t/could-not-send-message-casual-game-from-loader-go-loader-to-main-factories-startgame-solved/74712/4 "2023-10-28T16:16:01Z")

</div>

> [@schlista](#):
>
> ```lua
> if message_id == hash("proxy_loaded") then
> if game_mode == "casual" then
> msg.post("main:/factories#startgame", hash("casual_game"))
> end
> end
> 
> ```

Which category does this fit best in when inintially posted? I’m new here and not sure which one is best for this type of question.

Thank you.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 29, 2023, 10:07am UTC](https://forum.defold.com/t/could-not-send-message-casual-game-from-loader-go-loader-to-main-factories-startgame-solved/74712/5 "2023-10-29T10:07:03Z")

</div>

> [@schlista](#):
>
> Which category does this fit best in when inintially posted?

Usually the [Question category](https://forum.defold.com/c/questions/5) is the best, unless you know for sure that it is a bug in which case the [Bugs category](https://forum.defold.com/c/bugs/6) is best.
