Drag And Drop always: 'variable not set'

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Is your code really "global.global.variablename"? You don't need that second "global" if so
 
Show your code then, I'm going off this line in your screenshot
View attachment 27427
friend, i fixed this problem with THIS global variable but i have another problem with other global variable :/ (btw im huuge newbie)

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object przejsciemuzyka01:

global variable name 'MUZYKA01' index (100004) not set before reading it.
at gml_Object_przejsciemuzyka01_Create_0 (line 5) - if(global.MUZYKA01 == 1)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_przejsciemuzyka01_Create_0 (line 5)
 

rIKmAN

Member
friend, i fixed this problem with THIS global variable but i have another problem with other global variable :/ (btw im huuge newbie)

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object przejsciemuzyka01:

global variable name 'MUZYKA01' index (100004) not set before reading it.
at gml_Object_przejsciemuzyka01_Create_0 (line 5) - if(global.MUZYKA01 == 1)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_przejsciemuzyka01_Create_0 (line 5)
You need to create / initialise the variable before you can try and access it, this is why the error message says "not set before reading it".
You can't check if something equals 1 if it doesn't exist yet.

Create Event:
Code:
// create / initalise the variable
global.MUZYKA01 = 1;

// check if it equals 1
if(global.MUZYKA01 == 1)
{
    // do something
}
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
This is the same error as before, ie: the variable you are trying to reference has not yet been created. In general, you want to have ALL your global variables in a script, and then call this script in a room at the very start of the game. What I generally do is have an "initialisation" room, which is a room that has a single object in it, and in that object Create Event I set up all the cameras, global variables, buffers, etc... for the whole game and then go to the next room which is when my game ACTUALLY starts. This ensures that everything is set up before any other object needs to access it.
 
Top