• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

<unknown variable> ERROR halp

trying to make an object disappear on the click of another object. I'm getting this message when I click ANYTHING:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Mouse Event for Glob Left Pressed
for object object15:

Pop :: Execution Error - Variable references invalid object (-4).<unknown variable>
at gml_Object_object15_Mouse_53 (line 3) - objectClicked.object18 = image_alpha = 0;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_object15_Mouse_53 (line 3)

The "unknown variable" is object 18 and it is alive and well. here is my code:

var objectClicked = instance_position(mouse_x,mouse_y,object18 ); //this will either store noone or the id of the instance the mouse is on

objectClicked.object18 = image_alpha = 0;


HALP
 

CedSharp

Member
In the javascript language, it is possible to assign to more than one variable, like this:
Code:
var var1 = var2 = 5;
In GML, while it is very javascript-like, this is not possible and one would have to set each variable separately:
Code:
var var1, var2;
var1 = 5;
var2 = 5; // or var2 = var1;
Then, as @FrostyCat mentioned, the script you were calling can sometimes return a value which is not an instance. That special value is the constant "noone", which represents -4. When using scripts that return instance values, it's important to test against this constant.

Finally, if I understood your code correctly (and @FrostyCat beat me to it) you want to set image_blend of the returned instance. You don't usually access a variable of another instance with "=" but rather with ".". I assume this was simply a typo tho :p

Hope this helps a bit more to understand!
 
Top