I’m making a dinosaur game, similar to dinosaur simulator, but the menu system isn’t functioning correctly.
Every time the player hits play and then goes back to the menu, the buttons in the menu fire one more time than before. For example, if I play and go back to menu 3 times, and then go to buy a dino, It’ll register the button press 4 times and charge me 4x the amount and give me 4 of the dino.
I’ve tried adding debounce, but to no avail. the script seems to be running them all at the same time.
I don’t know what could be causing the problem because as far as I can tell the GUI isn’t being cloned or anything. It all just looks completely normal.
If anyone has come across this problem before and/or knows potential solutions, please tell me.
every time PlayerDied.OnClientEvent fires, you re-run all those :Connect() calls, stacking listeners, move your :Connect() calls out of the remote event handler, run them once on script load or GUI creation, then in OnClientEvent just toggle visibility or reset state, or store each connection in a variable and call conn:Disconnect() before reconnecting.
Glad you got a solution i’d recommend to stop using wait(x) and move to task.wait(x). It is apart of the task library it is a lot better to use and its a simple fix.