• 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!

Variable not set

C

CXXXV

Guest
I'm having this error and i don't have a clue what caused this.

The error messageproblem2.png

my writing
problem1.png
 
M

maartenvt

Guest
Take a look at this:
http://help.yoyogames.com/hc/en-us/articles/216755888--GMS-S-Variable-Scoping-In-GameMaker
You create local variables in the create event using "var", these variables will not be known outside the scripts or events you create them in.

Use var when you only need the variable in the script you are working on. Declare them without var if you want them to be know throughout the instance of an object. Create global variables if you need them to be known to every object in the game :)
 
C

CXXXV

Guest
Take a look at this:
http://help.yoyogames.com/hc/en-us/articles/216755888--GMS-S-Variable-Scoping-In-GameMaker
You create local variables in the create event using "var", these variables will not be known outside the scripts or events you create them in.

Use var when you only need the variable in the script you are working on. Declare them without var if you want them to be know throughout the instance of an object. Create global variables if you need them to be known to every object in the game :)
It works, thanks.
Is it a good practice to use function to change value of a variable?
 

jo-thijs

Member
He means having a script set the value of a global variable or an instance variable.

It kind of depends on what you want the script to do,
but if you can avoid it, you should definitely avoid it.
 
I

icuurd12b42

Guest
It's not bad practice but you should declare your variables in the create so you know what variables the object instances will use.
 
Top