Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

If then else statement not working?

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

✓ Accepted answer

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.

2 comments

0

Oh, I thought it did, good to know.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.