I am trying to make a debounce for a special ability (debounce is on the server so it is exploiter proof), and I am running into issues with table.remove. my debounce currently works because when you use the ability your put into a table, and then later when your debounce is over you are removed. here is my script:
if not table.find(Debounce, Plr.UserId) then
table.insert(Debounce, Plr.UserId)
--run ability
wait(10)
table.remove(Debounce, Plr.UserId)
end
I am 100% sure table.remove is the problem, this is because when I add a print(Debounce[1]) right before the if statement it prints nil the first time, and then when I wait 10 seconds and run it again it prints my user ID, showing it never got removed.
if not table.find(Debounce, Plr.UserId) then
table.insert(Debounce, Plr.UserId)
--run ability
task.wait(10)
table.remove(Debounce, Debounce[Plr.UserId]
end
if that is the case, wouldn’t table.remove(Debounce, Debounce[Plr.UserId]) not work? the index of the user ID is not the user ID, it is the place in the table it is, right?
Good question, have you tried it out to see if it works out? Because last I checked you could always find something in a table if you had an instance variable so I mean would make sense that you could index it with everything. Only way to know for sure it to try it out.