Button problem when entering scene in Storyboard

I went through the whole file and everything seems fine to me. No matter what I edit, I get the same error message to close out the bracket. [import]uid: 69494 topic_id: 30099 reply_id: 120898[/import]

there are several things wrong with how you declare functions. I’ve rewritten the file and it works!

change your create function to this

function scene:enterScene(event)  
  
 local displayGroup = self.view  
 print("mainmenu: enterScene event")  
  
 local backgroundImage = display.newImageRect("mainmenu.png", 480, 320)  
 backgroundImage.x = 240; backgroundImage.y = 160  
 displayGroup:insert(backgroundImage)  
  
 local storyBtn  
  
 local onPlayTouch = function(event)  
 if event.phase == "release" then  
 storyboard.gotoScene("levelselector", "fade", 300)  
 end  
 end   
  
  
 storyBtn = widget.newButton{  
 default.Src = "storybtn.png",  
 defaultX = 100,  
 defaultY = 100,  
 overSrc = "storybtn-over.png",  
 overX = 100,  
 overY = 100,  
 onEvent = onPlayTouch,  
 id = "StoryButton",  
 text = "",  
 font = "Helvetica",  
 textColor = {255, 255, 255, 255},  
 size = 16  
 }  
  
  
 storyBtn.x = 240; storyBtn.y = 440  
 displayGroup:insert(storyBtn)  
  
 btnAnim = transition.to(storyBtn, {time=500, y=260, transition=easing.inOutExpo})  
  
  
 local onOptionsTouch = function(event)  
 if event.phase == "release" then  
  
 -- audio.play(btnSound)  
 storyboard.gotoScene("options", "crossfade", 300)  
 end  
 end  
  
  
 local optBtn  
  
 optBtn = widget.newButton{  
 defaultSrc = "optbtn.png",  
 defaultX = 60,  
 defaultY = 60,  
 overSrc = "optbtn-over.png",  
 overX = 60,  
 overY = 60,  
 onEvent = onOptionsTouch,  
 id = "OptionsButton",  
 text = "",  
 font = "Helvetica",  
 textColor = {255, 255, 255, 255},  
 size = 16,  
 emboss = false  
 }  
  
 optBtn.x = 430; optBtn.y = 440  
 displayGroup:insert(optBtn)  
  
 btnAnim = transition.to(optBtn, {time=500, y=280, transition=easing.inOutExpo})  
  
 local arcadeBtn  
  
  
 local onOptionsTouch = function(event)  
 if event.phase == "release" then  
  
-- audio.play(btnSound)  
 storyboard.gotoScene("arcade", "crossfade", 300)  
 end  
 end  
  
  
 arcadeBtn = widget.newButton{  
 default.Src = "arcadebtn.png",  
 defaultX = 100,  
 defaultY = 100,  
 overSrc = "arcadebtn-over.png",  
 overX = 100,  
 overY = 100,  
 onEvent = onPlayTouch,  
 id = "ArcadeButton",  
 text = "",  
 font = "Helvetica",  
 textColor = {255, 255, 255, 255},  
 size = 16,  
 emboss = false  
 }  
  
  
 arcadeBtn.x = 240; arcadeBtn.y = 440  
 displayGroup:insert(arcadeBtn)  
  
 btnAnim = transition.to(arcadeBtn, {time=500, y=260, transition=easing.inOutExpo})  
  
 local brutalBtn  
  
  
  
 brutalBtn = widget.newButton{  
 default.Src = "brutalBtn.png",  
 defaultX = 100,  
 defaultY = 100,  
 overSrc = "brutalBtn-over.png",  
 overX = 100,  
 overY = 100,  
 onEvent = onPlayTouch,  
 id = "BrutalButton",  
 text = "",  
 font = "Helvetica",  
 textColor = {255, 255, 255, 255},  
 size = 16,  
 emboss = false   
 }  
  
 brutalBtn.x = 240; brutalBtn.y = 440  
 displayGroup:insert(brutalBtn)  
  
 btnAnim = transition.to(brutalBtn, {time=500, y=260, transition=easing.inOutExpo})  
  
  
end  

I don’t know what you’ve tried to accomplish with this

 local storyBtn  
  
 local onPlayTouch = function(event)  
 if event.phase == "release" then  
 storyboard.gotoScene("levelselector", "fade", 300)  
 end  
 end   

you declared a local variable storyBtn, but you put an “end” to it like it is a function.
It’ll only work if you’d it written like
[lua] local function storyBtn[/lua]
but you didn’t want to declate a function in the first place. That’s your missing bracket.

I’d simplify your 3 touch functions like this

local onBtnTouch = function(event)  
 if event.phase == "release" and event.target.id == "StoryButton" then  
 storyboard.gotoScene("levelselector", "fade", 300)  
  
 elseif event.phase == "release" and event.target.id == "OptionsButton" then  
 audio.play(btnSound)  
 storyboard.gotoScene("options", "crossfade", 300)  
  
 elseif event.phase == "release" and event.target.id == "ArcadeButton" then  
 audio.play(btnSound)  
 storyboard.gotoScene("arcade", "crossfade", 300)  
 end  
end  

[import]uid: 98393 topic_id: 30099 reply_id: 120907[/import]

You’re a life savor Paul_G! I’ll try these during my lunch hours at work. Btw, what are the names of the two games you have in the appstore? [import]uid: 69494 topic_id: 30099 reply_id: 120908[/import]