Game text code help to fix

print("Enter Your Name")
    name = io.read()
    print(name)
    
travellers = {}
    for i = 1, 3 do
    print("Enter the name of traveller".. i)
    travellers[i] = io.read()
    
end

print("You and your fellow travelers come a cross a cave and go inside")
print("Once inside you see a fork in the path")
print("Do you choose path 1 or 2")
choice = io.read()

if choice == 1 then
    print("you enter an open room and see a chest against the wall, you open it and its full of gold")
    print("you and your fellow travelers are now rich")
    
elseif choice ==2 then
    print("You and your buddies walk in to a dead end")
    print("without warning bandits ambush you and kill everyone")
    print("game over")
else
    print("invalid choice")
end

@Willkassens Welcome to the forum! You are close, but Codea does not use io.read(). If you look around the forums you will see multiple post on using the keyboard for your “choices”

Also, use three ~'s to format before and after your code
Example:
(Take out the spaces)

~ ~ ~

Code Here

~ ~ ~

I fixed your formatting as suggested by CodeaNoob

@Willkassens Just to give you an idea of what it takes to do what you’re trying, here’s one way to do it. Press “return” after each entry.


displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)

function setup()
    showKeyboard()
    trav={}
    nbr=1
    choice=0
end

function draw()
    background(40,40,50)
    text("Travelers",100,800)
    for a,b in pairs(trav) do
        text(b,100,800-a*20)
    end
    getNames()
    getPath()
    takePath()
    checkInput()
end
      
function keyboard(k)
    if k==RETURN then
        ret=true
        hideKeyboard()
        showKeyboard()
    end
end  

function checkInput()
    if ans=="\
" then
        hideKeyboard()
        showKeyboard()
    end        
    if ans~=nil and ans~="" then
        text(ans,WIDTH/2,HEIGHT-250)
    end
    if not ret then
        ans=keyboardBuffer()
    end
end

function getNames()
    fill(255)
    if nbr>0 and nbr<4 then
        text("Enter the name of traveler   "..nbr,WIDTH/2,HEIGHT-100)
        if ret then
            trav[nbr]=ans
            nbr=nbr+1
            ret=false
        end
    end
end

function getPath()
    if nbr==4 then
        str=
        [[
           You and your fellow travelers come a cross a cave and go inside.
           Once inside, you see a fork in the path.
           Do you choose path 1 or 2
        ]]
        text(str,WIDTH/2,HEIGHT-100)
        choice=tonumber(ans)
        if ret then 
            ret=false
            if choice==1 or choice==2 then
                nbr=nbr+1
            end
        end
    end    
end

function takePath()
    if nbr==5 then
        if choice == 1 then 
            str=
            [[
               You enter an open room and see a chest against the wall.
               You open it and its full of gold. 
               You and your fellow travelers are now rich.
            ]]
        elseif choice == 2 then 
            str=
            [[
               You and your buddies walk in to a dead end.
               Without warning, bandits ambush you and kill everyone.
               Game over.
            ]]
        end
        text(str,WIDTH/2,HEIGHT-100)
    end
end

Better, in Codea, is to draw a couple of on screen buttons and get the user to touch one of them. Entering 1 or 2 is for old DOS machines!

Thanks everyone! You’ve helped tons!