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

Need help, getting syntax error in breakthrough game from the tutorial

K

kiyogity

Guest
Hello, I am completely new to programming and I tried following along with this tutorial to make my first game. However when I run my game I get a syntax error.

ERROR in
action number 1
of Step Event0
for object obj_Bat:

Variable obj_Bat.go(100003, -2147483648) not set before reading it.
at gml_Object_obj_Bat_Step_0 (line 28) - if !go x = other.x;
############################################################################################
gml_Object_obj_Bat_Step_0 (line 28)

______

This is my code here:

Code:
/// @description Move
if keyboard_check(vk_left) // Check for the left qrrow key being held down
    {
        // This check is to make sure the bat doesn't go out of the room to the left
        if x > sprite_get_xoffset(sprite_index) + spd
        {
        x -= spd; //Move the bat
        }
    else
        {
            x = sprite_get_xoffset(sprite_index); // Clamp the bat to the leftmost side
        }
    }
    if keyboard_check(vk_right) // Check for the right arrow key being held down
        {
            // This check is to make sure the bat doesn't go out of the room to the right
            if x < room_width - sprite_get_xoffset(sprite_index) - spd
                {
                    x += spd;
                }
            else
                {
                    x = room_width - sprite_get_xoffset(sprite_index);
                }
        }
        // Moves the ball object w the bat if the ball isn't moving yet w (obj_ball)
        {
             if !go x = other.x;
        }
 

Slyddar

Member
Variable obj_Bat.go(100003, -2147483648) not set before reading it.
This line means the obj_Bat object is trying to access a variable called go, hence the obj_Bat.go part, and the variable is not set before reading it, meaning it can't find it.

When you reference a variable, you need to ensure it has been created, or 'declared', first. There is a section in that video where she creates the go variable in the create event. You need to do that first. Add a CREATE event and declare the variable like so :
Code:
go = false;
 
K

kiyogity

Guest
This line means the obj_Bat object is trying to access a variable called go, hence the obj_Bat.go part, and the variable is not set before reading it, meaning it can't find it.

When you reference a variable, you need to ensure it has been created, or 'declared', first. There is a section in that video where she creates the go variable in the create event. You need to do that first. Add a CREATE event and declare the variable like so :
Code:
go = false;
Thanks so much, programming is frustrating, I was trying to fix this for a day!
 
Top