GUI component could not be found when dispatching message error? SOLVED

Am having trouble trying to get the gameOver GUI on screen. When program is run it says that “Component ‘/gui#gameOver’ could not be found when dispatching message ‘disable’ sent from main:/script#tetris”.

The program runs but just doesn’t display the gameOver GUI.

Other GUI being used (score GUI) works fine.

It should be possible to enable/disable the gameOver GUI without a gameOver GUI script because it is just about enabling/disabling it with no more functionality, this should be able to be done just from the main script.

Any help is appreciated, thanks!

image

It looks like you are confusing the folder structure of your project (ia the Asset panel) with the actual scene hierarchy of your collection. You do not post a message to the path of the file in your project but to how you have structured your scene hierarchy.

What does your collection look like? The url “/gui#gameOver” assumes that you have a game object with id “gui” and a gui component in that game object with is “gameOver”. Is that the case?

Here is the main collection:

you’re right, i didnt have a game object called gameOver so i add that in to the main collection here:

but now when it runs it just has the game over GUI plastered on screen, does that mean thats an issue in the script?


Gui always show along with the game object containing it.
You can add a root node and set it to not Enabled to hide it at beginning. And then when you want to show it, use gui.set_enabled(gui.get_node("root"), true).
A simplier way is to set disable its game object.

Looking at your code I think you should know that gui has no enable, disable message, so mgs.post("/gui/gameOver.gui", "disable") will not work. Also use “/gui#gameOver” url instead

All sorted, thanks all