Could not send message '[the message]' from 'main:/controller#main' to 'game_proxy:/player#player_script' - But the URL is correct

The error is:
main/main.script:31: Could not send message ‘easy’ from ‘main:/controller#main’ to ‘game_proxy:/player#player_script’.
stack traceback:
[C]:-1: in function post
main/main.script:31: in function <main/main.script:11>

i’m sending this message from the main script:
msg.post("game:/player#player_script", "easy")

and when I look at the URL from the player_script in the player object in the player collection with print(msg.url()) it is the same. Yet i get the issue as if the msg.post cannot find the url

thanks so much for any help at all!

Is it game or game_proxy? Either way a common mistake that results in that error is sending the message before the proxy loads. Sending the message immediately like this:

msg.post("#proxy", "load")
msg.post("game_proxy:/player#player_script", "easy")

won’t work because the proxy hasn’t had time to load yet. Instead, wait to receive the proxy_loaded message first:

msg.post("#proxy", "load")
function on_message(self, message_id, message)
    if message_id == hash("proxy_loaded") then
        msg.post("game_proxy:/player#player_script", "easy")
    end
end
3 Likes

Thank you so much for the help!

It was the fact that the proxy was not fully loaded so in the message_id == proxy loaded I made a condition to send the message.

1 Like