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

When stepped on, run script, but without lags?

Asked by 3 years ago
Edited 3 years ago

I have a button, but when I stepped on it, the script runs few times. It would seem that use Debounce and all problems will disappear, but no, then TouchEnded will stop working.

This simple task left me in a stupor, I have always used Debounce, but in this case it is useless.

What i tried:

Debounce

All variants with Debounce

Region3

Raycast

Script:

script.Parent.Touched:Connect(function()
    print("stepped on")
end)

script.Parent.TouchEnded:Connect(function()
    print("stepped off")
end)

Debounce Version:

Debounce = true 

script.Parent.Touched:Connect(function()
    if Debounce == true then
        Debounce = nil
        print("stepped on")
        wait(1)
        Debounce = false
    end
end)

script.Parent.TouchEnded:Connect(function()
    if Debounce == false then
        Debounce = nil
        print("stepped off")
        wait(1)
        Debounce = true
    end
end)

Help me please.

0
Could you include the script where you attempted to use debounce? Neatwyy 123 — 3y
0
@Neatwyy Yes, I add it. LioshaPlay 66 — 3y

Answer this question