GML Visual I suck at working with global variables, help me.

H

HexDev

Guest
Basically what this is supposed to do is that when a local variable has a certain value it sets a global variable with a value of 1, then another object gets that global variable and if the value of that variable is 1 then it plays a sound and the instance of this object gets deleted. But its not working, help.
Captura de pantalla (59).png
Captura de pantalla (61).png
Captura de pantalla (60).png
(error screen that appears when I try to start the game)
 

Evanski

Raccoon Lord
Forum Staff
Moderator
The object checking for hexdies is trying to read the global before the global is created,
have an object/script/ or ect set the global to = 0, before other instances ask for what the global is
 
  • Like
Reactions: Tyg
H

HexDev

Guest
The object checking for hexdies is trying to read the global before the global is created,
have an object/script/ or ect set the global to = 0, before other instances ask for what the global is
I did that, doesn't work
 
H

HexDev

Guest
Where and how did you do that? I'm going to pre-emptively suggest that you did not, in fact, do "that", but instead, did something other than what was suggested, and that's why it didn't work.
I made an object with a "game start" event, and in that event I set the global variable to 0. Just like you suggested.
 

Nidoking

Member
I didn't suggest anything. However, the Game Start event will run after all Create events, so as I said, you did not put the initialization before Create events. You may find that the suggestion, which again, was not from me, was to put it in a script.

You might also want to get into the habit of creating an initialization room, where something performs initialization and then changes to your first actual room, and you have no instances of any non-persistent game objects. In that case, the Game Start event of such an object would work.
 
Top