for example,
local Debounce = true
button.MouseEnter:Connect(function()
if Debounce then
--whatever
end
end)
or
while wait() do
button.MouseEnter:Wait()
--whatever
end
for example,
local Debounce = true
button.MouseEnter:Connect(function()
if Debounce then
--whatever
end
end)
or
while wait() do
button.MouseEnter:Wait()
--whatever
end
:Wait()
leaves a hanging thread and requires that there be nothing else after that loop (in your case).
A debounce would be better. However, I’ve always been a fan of:
local lastUsed = 0
EventName:connect(function()
if tick() - lastUsed <= COOLDOWN then return end
lastUsed = tick()
-- code
end)
No particular reason, you could argue it’s more optimal than wait(COOLDOWN)
, but I just prefer it.
so tick is the best method?
Use whatever you prefer. I prefer tick() since it leaves no hanging threads.
alright, thanks for the help!