Ideas for seating system

i was thinking about making a seating system that could be used in my restaurant game. how it would work: a staff member would open a GUI that has a list of tables on it. if the table is taken (the table would have a BoolValue), it would be red, and there can’t be anyone seated there. if it was green, the staff can add as many users as the table can hold (a value with the number of seats in the table part). after that, they can assign the users to the table and it will make sure no one can assign anyone else.

i was thinking about using values inside the table parts to see if it’s taken, who’s sitting there, how many people it can hold. then, in the system ui, it would loop through the table parts and find if they are taken or not, and then color and or disable the button based on if it’s taken or not taken. when the users are assigned, i was thinking either i could use a remote event or something else to assign them to that table.

any feedback or ideas that you think could make it better would be appreciated.
thanks!

1 Like

You could do this very easily in a way that would be clean and organized through the use of object oriented programming. So you would in theory create a table class which might contain the seats and stuff and then maybe a boolvalue.

Once you have your object just store them in a table in a serverscript somewhere.

If a worker needs to retrieve which spots are open you have a remotefunction return a table of boolean values for which tables are open. Simple as that.

I would read some articles here on the devforum regarding oop to familiarize yourself. However this would be my approach.

4 Likes

thanks for the advice! this sounds much cleaner than my idea.

Yeah no worries. You could also just have a table containing subtables with the specified data you need for it. But it wouldnt really allow for you to have clean methods that can be called upon with the object.

2 Likes

so for example, when we seat new people, we get the table and change the values based on what table was chosen, right?

So when your assigning other users you just have the same remote function i said you should use be invoked with the players you want to sit there, and you just have the name of the table be passed in as a parameter, than you might have a method in the resturaunt table object called SetOccupants which just tells it if the table is taken or who is sitting there. So if the table object in the script that holds the remote function connection you just do

resturauntTbls[tablename]:SetOccupant(some parameter)

1 Like

yeah ok. thanks so much for your ideas!! :slight_smile:

No probs you can message me on devforum if you have ANY questions about the code itself and ill get back to you when i see it. Good Luck!

1 Like

so i got started with oop doing only one person per table, and it’s working well. the only thing i’m wondering about is how can i get it so that it lets up to the maximum amount of people be added to sit at the table?

example:

self.guest = player

but how can i make it for more than one player, and up to the maximum for the table?