Help with flappy

Ok so in my high school I’m taking an intro to programming class and we are using Codea as our base programming system. I’m trying to create a flappy bird simulation like the demo version given. Except I’m not allowed to use tables or anything really complicated. Just a base game of a “bird” jumping up and down through pipes that spawn randomly with a gap between the pipes that stays the same. It has to keep track of score too. I got the bird done and I’ve begun working on just getting the first pipe to spawn but w/o collision detection. I ran into and error with it and I could use some help with getting the pipe to run off the screen then resplendent a different hight here’s my code

function setup()
        
    x=100
    y=300
    radius=50
    speedY=-3
    speedX=-3
    x1=WIDTH
    y1=math.random(0,-WIDTH)
    pipeH=HEIGHT --this variable isn't being used yet it's for later
    print(HEIGHT,WIDTH)
    gap=200
end
function draw()
    background(109, 226, 36, 255)
    fill(255, 0, 0, 255)
    
    ellipse(x,y,radius)
    y=y+speedY
    speedY=speedY-.2
        if speedY>6.5 then speedY=6.5
        end
        if speedY<-6.5 then speedY=-6.5
        end
    rect(x1,y1,50,250)
    x1=x1+speedX
        if x1<=-50 then x1=WIDTH
        end
end
function touched(touch)
    if touch.state==BEGAN
    then speedY=speedY+13
    print("touch")
        
    end
end

Please read the FAQ to see how to post code in the forum so that it formats correctly:

http://codea.io/talk/discussion/275/faq-please-read

@Mark.T When you post code, put 3~'s on a line before and after your code.

^thank didn’t know it had an affect but thank you

@Mark.T I corrected your error and added a few lines of code to get you going.

function setup()
    x=100
    y=300
    radius=50
    speedY=-3
    speedX=-3
    gap=200
    x1=WIDTH
    y1=math.random(10,HEIGHT-gap)
    pipeH=HEIGHT --this variable isn't being used yet it's for later
    print(HEIGHT,WIDTH)

end
function draw()
    background(109, 226, 36, 255)
    fill(255, 0, 0, 255)
    ellipse(x,y,radius)
    y=y+speedY
    speedY=speedY-.2
    if speedY>6.5 then 
        speedY=6.5
    end
    if speedY<-6.5 then 
        speedY=-6.5
    end
    rect(x1,0,50,y1)
    rect(x1,y1+gap,50,HEIGHT)
    x1=x1+speedX
    if x1<=-50 then 
        x1=WIDTH
        y1=math.random(10,HEIGHT-gap)
    end
end
function touched(touch)
    if touch.state==BEGAN then 
        speedY=speedY+13
        print("touch")
    end
end

@dave1707 thank you. This code I compared your code to mine and I guess I see what I did wrong. Thank you for your help!