Reloading collection proxy crashes

Hi! I am currently working on a game. When i restart, i have a proxy that want to reload, but it crashes the game. I don’t know if i am doing something wrong, but i think it’s a bug.
This is the snippet of code:
( i send restart)

function on_message(self, message_id, message, sender)
print(“message!”)
if message_id == hash(“proxy_loaded”) then
– New world is loaded. Init and enable it.
msg.post(sender, “init”)
msg.post(sender, “enable”)
elseif message_id == hash(“restart”) then
msg.post("#myproxy", “disable”)
msg.post("#myproxy", “final”)
msg.post("#myproxy", “unload”)
msg.post("#myproxy", “load”)
end
end

Console(Not in code):
ERROR:GAMEOBJECT: The collection ‘main’ could not be created since there is already a socket with the same name.

You probably want to change that to

function on_message(self, message_id, message, sender)
   print("message!")
   if message_id == hash("proxy_loaded") then
      -- New world is loaded. Init and enable it.
      msg.post(sender, "init")
      msg.post(sender, "enable")
   elseif message_id == hash("restart") then
      msg.post("#myproxy", "disable")
      msg.post("#myproxy", "final")
      msg.post("#myproxy", "unload")
   elseif message_id == hash("proxy_unloaded") then
      msg.post("#myproxy", "load")
   end
end

so that the code waits until the collection is fully unloaded until reloading it.

2 Likes

A crash is always a bug.
Please provide a small example project which produces the issue that we can look into.