Syntax error: E:\main.lua:54: unexpected symbol near '['

Could someone please help me with this?
Here’s the code

function CreateLevelSelect()  
 local Level = { }  
 for i=1,10,1 do  
 local Level[i] = ui.newButton {  
 default = "Levelbutton.png",  
 onRelease = StartLevel(i),  
 text = i,  
 emboss = true   
 }  
 end  
end  

As you can kind of see, I’m trying to make each Level[] in the array be a button by using a loop to create 10 buttons, but I get this error: Syntax error: E:\main.lua:54: unexpected symbol near ‘[’

How do I correctly do this? I’ve tried to figure it out for a good hour now and a bunch of google searches.

[import]uid: 44393 topic_id: 7780 reply_id: 307780[/import]

remove the word local in front of Level[i]

also your onRelease function won’t work… whenever you add () on the end of a function it calls it immediately.

since I don’t know how the rest of your code is set up the simplest solution is to wrap it in an anonymous function closure

[lua]onRelease = function() StartLevel(i) end,[/lua]
[import]uid: 6645 topic_id: 7780 reply_id: 27593[/import]

Thank you sir. [import]uid: 44393 topic_id: 7780 reply_id: 27595[/import]