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

If then else statement not working?

Asked by 3 years ago

I'm trying to make a Gate and it's going pretty well, and it works well too, however, the problem is the debounce variable I've set up for it is not working.

Button.MouseClick:Connect(function()

if DoorDebounce == false then
        DoorDebounce = true 
        if DoorIsUp then
            Door.Anchored = false
            print("Door is lowering")
            DownTween:Play()
            Door.Anchored = true
            DoorIsUp = false
        else
            Door.Anchored = false
            print("Door is opening")
            UpTween:Play()
            DoorIsUp = true
            Door.Anchored = true
        end
        DoorDebounce = false 
    end

end)

What am I doing wrong?

1 answer

Log in to vote
1
Answered by
bdam3000 125
3 years ago

I think you forgot the wait() for the debounce to be set to false. Playing a tween doesn't wait for the tween to finish to play the rest of the code.

0
Oh, I thought it did, good to know. generalYURASKO 144 — 3y
0
Hold on, it keeps it from being clicked two times in quick succession, but the wait for some reason screws up the script when the door is going down. generalYURASKO 144 — 3y
Ad

Answer this question