Unexpexted Symbol Error

There’s a bug that I can’t figure out where in the Ballon:resert() function, on the if col == BLUE then line it says that there is an un-expected symbol near if when the function is called. When the ballons are created it selects a random color which is the parameter colour (how the english spell color). Any guesses?

EDIT: The color system worked fine before I implemented the colors in the reset function.

Ballon = class()

RED = 0
BLUE = 1
YELLOW = 2
FIRST = RED
LAST = YELLOW

function Ballon:init(x,colour)
    colour = self.col
    
    if self.col == RED then
        self.ballonColor = vec4(198, 53, 25, 123)
        self.ballonSpeed = 10
    
    elseif self.col == BLUE then
        self.ballonColor = vec4(43, 33, 223, 123)
        self.ballonSpeed = 2
    
    elseif self.col == YELLOW then
        self.ballonColor = vec4(202, 223, 33, 123)
        self.ballonSpeed = 5
    end

    self.ballonX = x
    self.ballonY = 10
    self.ballonHeight = 150
    self.ballonWidth = 100
    
 end
function Ballon:reset()
    
    if self.col == RED then
        ballonSpeed = 8
    elseif
        
    if self.col == BLUE then
        ballonSpeed = 8
    elseif
    
    if self.col == YELLOW then
        ballonSpeed = 5
    elseif
        print("Ballon does'nt have a color")
        ballonSpeed = 0
       end
        
    self.ballonX = math.random(200, WIDTH - 50)
end

You have some syntax errors with how you have constructed your if statements in the function reset
spot the difference with this version.

Ballon = class()

RED = 0
BLUE = 1
YELLOW = 2
FIRST = RED
LAST = YELLOW

function Ballon:init(x,colour)
     self.col = colour

    if self.col == RED then
        self.ballonColor = vec4(198, 53, 25, 123)
        self.ballonSpeed = 10

    elseif self.col == BLUE then
        self.ballonColor = vec4(43, 33, 223, 123)
        self.ballonSpeed = 2

    elseif self.col == YELLOW then
        self.ballonColor = vec4(202, 223, 33, 123)
        self.ballonSpeed = 5
    end

    self.ballonX = x
    self.ballonY = 10
    self.ballonHeight = 150
    self.ballonWidth = 100

 end
function Ballon:reset()

    if self.col == RED then
        ballonSpeed = 8
    elseif self.col == BLUE then
        ballonSpeed = 8
    elseif self.col == YELLOW then
        ballonSpeed = 5
    else
        print("Ballon does'nt have a color")
        ballonSpeed = 0
    end

    self.ballonX = math.random(200, WIDTH - 50)
end

I also suggest not to use globals in the way you have (RED,GREEN etc) and perhaps consider setting the actual colour and speed in the constructor. To reset just create a new balloon :slight_smile:

0_0 I feal so stupid. I really should have figured that one out on my own. Im so sorry. Thanks though.