Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

should the first line with debounce be local or not?

Asked by 5 years ago
local debounce = false

clicker = script.Parent.ClickDetector
clicker.MouseClick:Connect(function()
    if not debounce then debounce = true
        print("event fired")
        wait(3)
        debounce = false
    end
end)

ive used debounce as it is but after looking up two sources one uses local debounce in the first line and another does not use local for debounce. does it matter or does this impact how debounce works?

0
i dont know if it inpacts it but i do put local mattchew1010 396 — 5y
0
The difference between local and global variables is one of both security and good habit. Just as exploiters can use powerful debug methods to manipulate global variables in real time, it also helps ensure you do not overwrite your own variables by localizing them to the stack level. CorruptScript 86 — 5y
0
ok, while on the subject of debounce I am having a problem with players using autoclickers in my game(or possibly another external program) , one of my scripts that uses this debounce method is still getting overloaded, can these programs break debounce and bypass it? mantorok4866 201 — 5y
0
Externally no, internally yes. If the debounce is not local, exploiters can use this to their advantage to manipulate it, but even this wouldn't help your case as debounce would become an exploitable upvalue due to its use in the unlisted function bound to the .MouseClick event. If your code relies on remotes, you should always run such debounces from the Server to prevent exploitation. CorruptScript 86 — 5y
View all comments (3 more)
0
the variable 5should be local because it's faster and functions see local variables in every scope of the function DeceptiveCaster 3761 — 5y
0
so the scripts that are being exploited are fire scripts inside guns(normal scripts inside a tool), so no remote events are being used. but some weapons are bypassed and I cant figure out why some are and some are not. they all have the same mechanics and debounce is the same for all of them. mantorok4866 201 — 5y
0
In that case, functions connected to RbxEvents are threaded. That being said, it's perfectly plausible that the click event could potentially get overloaded and change the value of debounce prematurely. I recommend looking into the :wait() method instead.  http://wiki.roblox.com/index.php?title=User:JulienDethurens/Essays/Wait_method CorruptScript 86 — 5y

Answer this question