• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML problem with instance variable

M

Mickachu

Guest
Hi, i am kinda new to GMS2 and i need some help. I would like to create an instance variable called "hello" but GameMaker do not recognize it as an instance variable (in green) like "score". I would like to understand why it is doing this and how to fix it. By waiting, I wish you a nice day ;)
 

Attachments

H

Homunculus

Guest
That is correct. Instance variables are highlighted in blue.

score is a built in variable, which is highlighted in green. Note that both built in instance and global variables are green (score being global in this case)
 
M

Mickachu

Guest
Oh so I need to put global. in front of it. Thanks a lot and sorry for the disturbance, maybe if I searched a bit more I would have found the solution by myself. Have a great day!
 
H

Homunculus

Guest
No you don't, your code is just fine. What I meant to say is that built in variables have a different color than user defined variables. Global AND instance variables that are built in are green, and for the global ones you don't need the "global" prefix.

Also note that "score" (along with "health" and "lives") are deprecated global built in variables, meaning that while they work as intended, you should avoid using them.
 

TsukaYuriko

☄️
Forum Staff
Moderator
No, that's not at all what was said.

score is a built-in variable, this is why it is colored differently. It has nothing to do with it being a global or not and nobody suggested you to make it global.

If you want instance variables to be green, you can change their color in the settings. Don't make them global just for that. It's fine the way you're doing it in the opening post.
 
Top