I have updated the provided code, and the script only have one part that used to display the menu, should at least try amend it instead of keep asking for spoonfeed and saying error without provide any details.
this version isn't recommended because there is a small bug where it skip items when attempt to generate the menu, causing wrong item index.