Error: Expected "(" near object

Hello all,
I was working on an app and just came across director class and decided to implement it into my code. I was writing my menu code when I saw that the terminal produced an error that said:
“menu.lua:43: ‘(’ expected near ‘playButton’”.
When I inserted a ( before the playButton, terminal produced an error that said:
“menu.lua:43: ‘)’ expected near ‘=’”
When I put a ) in front of the equals sign, then I get an error (not suprisingly):
“menu.lua:43: unexpected symbol near ‘=’”
What is wrong with my code (here at the bottom)? Can anyone help with this?

[lua]playButton = ui.newButton{
default = “Images/buttonWhite.png”,
over = “Images/buttonWhiteOver.png”,
onRelease = playButtonRelease,
text = “PLAY”,
font = “Arial Black”,
textColor = { 0, 0, 0, 255 },
size = 36,
emboss = true
}
playButton.x = 240
playButton.y = 75
localGroup:insert( playButton )[/lua]
[import]uid: 38000 topic_id: 15866 reply_id: 315866[/import]

did you try using

playButton = ui.newButton({

})

and it is very difficult to know what line 43 of your code is… it would be helpful if you had a small note that said for example, the code line 1 is line 40 in the menu.lua

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 15866 reply_id: 58666[/import]

I tried that, but it doesn’t seem to make a difference. And for the record, line one here is line 42 in the code.
I recently was moving my app to Director Class, and this works fine on my old version, so I may have messed something up by changing it.
Here is the full code:
[lua]module(…, package.seeall)

new = function ()

local ui = require ( “ui” )

local vLabel = “”
local vReload = false

if type( params ) == “table” then

if type( params.label ) == “string” then
vLabel = params.label
end

if type( params.reload ) == “boolean” then
vReload = params.reload
end

end

local localGroup = display.newGroup()
local background = display.newImage( “ocean.png”, true )

local playButtonRelease = function(event)
director:changeScene( “play”, “crossfade” )
end
playButton:addEventListener( “tap”, playButtonRelease )

local howButtonRelease = function(event)
director:changeScene( “how”, “crossfade” )
end
howButton:addEventListener( “tap”, playButtonRelease )

local aboutButtonRelease = function(event)
director:changeScene( “about”, “crossfade” )
end
aboutButton:addEventListener( “tap”, aboutButtonRelease )

local settingsButtonRelease = function(event)
director:changeScene( “settings”, “crossfade” )
end
settingsButton:addEventListener(“tap”, settingsButtonRelease)

local function MainMenu
playButton = ui.newButton{
default = “Images/buttonWhite.png”,
over = “Images/buttonWhiteOver.png”,
onRelease = playButtonRelease,
text = “PLAY”,
font = “Arial Black”,
textColor = { 0, 0, 0, 255 },
size = 36,
emboss = true
}
playButton.x = 240
playButton.y = 75

local howButton = ui.newButton{
default = “Images/buttonWhite.png”,
over = “Images/buttonWhiteOver.png”,
onRelease = howButtonRelease,
text = “HOW TO PLAY”,
font = “Arial Black”,
textColor = { 0, 0, 0, 255 },
size = 32,
emboss = true
}
howButton.x = 240
howButton.y = 135
localGroup:insert( howButton )

local aboutButton = ui.newButton{
default = “Images/buttonWhite.png”,
over = “Images/buttonWhiteOver.png”,
text = “ABOUT”,
font = “Arial Black”,
textColor = { 0, 0, 0, 255 },
size = 36,
emboss = true
}
aboutButton.x = 240
aboutButton.y = 195

local settingsButton = ui.newButton{
default = “Images/buttonWhite.png”,
over = “Images/buttonWhiteOver.png”,
text = “SETTINGS”,
font = “Arial Black”,
textColor = { 0, 0, 0, 255 },
size = 36,
emboss = true
}
settingsButton.x = 240
settingsButton.y = 255

local initVars = function ()
localGroup:insert( background )
localGroup:insert( settingsButton )
localGroup:insert( aboutButton )
localGroup:insert( howButton )
localGroup:insert( playButton )
print(“Initializing Home”)
end

clean = function()
print(“Cleaning Home”)

end

mainMenu()
initVars()
return localGroup
end[/lua]
Thanks for your help! [import]uid: 38000 topic_id: 15866 reply_id: 58755[/import]

I’m guessing line 45 in the snippet you posted should be:

[lua]local function MainMenu()[/lua]

i.e. the empty parens after the function declaration [import]uid: 21712 topic_id: 15866 reply_id: 58773[/import]

Thank you! That seemed to fix it. It was just a simple coding mistake on my part after all. Thank you so much for your help. [import]uid: 38000 topic_id: 15866 reply_id: 58795[/import]