I’m pretty new to scripting and I can’t seem to figure what is going on with this part of my code. Basically, when the President enters a safe room in less than 10 seconds, the round ends and the President/Bodyguards win. I should note that when the president enters the safe room, the floor has a ‘Touched’ event (I don’t know how to detect if a player is inside of a brick so I used a floor(or if you can even do that)). However when the president enters the safe rom and touches the floor, the message I used to test if the code gets spammed, gets spammed and repeats everything in the function multiple times causing some serious lag. I’m confused because I triple checked to make sure the debounce is correct and I can’t find anything wrong with it. I have a screenshot of the console in-game: https://gyazo.com/6bab7a8cc478423134caa0ef80e07324
I think it may have to deal with the code used to end the round if the President doesn’t make it to one of the safe rooms, along with other variables which should be pretty self-explanatory, not sure though: https://gyazo.com/7250b2dc0495fcaa9d36eb8d2c1146d9
I’ve looked all over the internet and it has been driving me crazy, I might be missing something or I could be doing something completely wrong. Once again I am pretty new to scripting, so please go easy on me heheh.
EDIT
Problem resolved, thank you to everyone who contributed in helping me and giving some great tips!
instead of doing “if not deb then” on line 181, you do “if deb == false then”. Here’s a tip: next time you encounter a problem you should use print commands to locate the problem, that’s how many devs do it, in this case, you would do “print(deb)” on line 183, and if the output was false, then you would know that there is a problem around there.
if not deb is equal to if deb == false, as with other booleans. Of course it can be confused with the boolean being nil, but it shouldn’t be a worry in this instance.
If there isn’t an end after the code under the if statement, it isn’t closed. Right now the script thinks that there is also an elseif statement, which is confusing the script.
Also, I suggest indenting your code correctly so you don’t get as easily confused. It’s a good habit to have when coding!
the amount of “if” and “function” statements is the number of ends, desired was right, indenting is a good habit — you can tell how much ends there are by the number of indents.