Thanks. I’ve received the project. The problem was indeed that the endscreen wasn’t loaded when you tried to send the message. This is what your code looked like:
local function load_endscreen(self)
msg.post("go#endscreen", "load")
msg.post("go#endscreen", "enable")
end
function on_message(self, message_id, message, sender)
if message_id == hash("scorePass") then
load_endscreen(self)
msg.post("endscreen:/go#endscreen", hash("scorePass"), scoreTable)
unload_endscreen(self)
end
end
The call to msg.post("go#endscreen", "load")
will send a message to load the endscreen BUT since msg.post() is an asynchronous operation it means that it won’t complete immediately. Your code will continue to execute and you will send an “enable” message (also async) and then you will immediately proceed to also send a “scorePass” message.
The next things that happens is that the engine will process the messages in order:
- “load”
- “enable”
- “scorePass”
The problem here is that you have not given the loaded collection and the game objects and components inside time to initialize. Your “enable” message will most likely be ignored and your “scorePass” message will not be able to reach “endscreen:/go#endscreen” since the components haven’t been initialized.
What you need to do is to wait until you receive a “proxy_loaded” message before you proceed to send the “scorePass” message.
You read more about loading collection proxies in the manual: