Using DirectButton for different commands [solved]

I’m making a simple game that involves multiple rooms. Each room is a function, and I want to use DirectButton to move through the different rooms. What is the best way to do this? First I created the button, then for each room I changed the value of the command keyword to the appropriate function, but unfortunately I got a World instance has no attribute “button” error.

self.button["command"]=function

I suppose I could create a new button within each function but as I expand the game with multiple buttons and more rooms I imagine there has to be a more efficient way.

Nevermind I got it. Simple mistake, I created the button after I called the function that’s why the instance couldn’t find it…