Yes, I tested your code because I could see quite a few problems, but I do like how you're using your tables.
That error is because of this line:
centerPrint("[ "..menu[selectedItem].text.." ]",i+5)
--and
centerPrint(" "..menu[selectedItem].text.." ",i+5)
It should be:
centerPrint("[ "..menu[i].text.." ]",i+5) -- Should print menu[i].text because you're looping through a table
--and
centerPrint(" "..menu[i].text.." ",i+5)
Another one would be the "selectedMenu" variable. You made it a string:
local selectedMenu = "MainMenu"
This will not work, you need to make it the table, which is defined only later so you will have to set this variable after defining the table.
local selectedMenu = MainMenu
Another one, last one (i think) is using the handler, when clicking enter. Just before it calls the function, you change the selectedItem to 1, but why?
Also, for the handlers within the MainMenu table, instead of calling the function which only has one, do this to reduce lines significantly:
local MainMenu = {
[1] = {text = "Programs", handler = function() selectedMenu = "Programs" end},
[2] = {text = "Control Options", handler = function() selectedMenu = "Control" end},
[3] = {text = "Redstone Options", handler = function() selectedMenu = "Redstone" end},
[4] = {text = "Exit", handler = function() running = false end}
}
Fixed code?