What I'm making is a type of "Control Panel" thing that uses Surface GUIs and some brick rotations as "pages" for the Control Panel.
This is what it looks like and that "NEXT" button rotates the brick 90 degrees.
This gif shows how the next button works.
But after that the rotation doesn't work anymore, and it kind of twitches like this. (Unable to see the twitching effect through the gif, I'll provide a link so you can see the twitching directly in game.)
Here's the code for the "NEXT" button:
local screen = script.Parent.Parent.Parent.Parent
bin = script.Parent
bin.MouseButton1Click:connect(function()
for i = 1, 90 do
screen.Rotation = screen.Rotation + Vector3.new(0, 1, 0)
wait()
end
end)
If you could give me an explanation as to why it just sort of twitches that way after the first use, it'd be much appreciated!
Here's a link to the game to check it out for yourself.
Thanks!

2 comments
Thanks a bunch! But one question, on line 6, how would it know if the debounce variable is true or not without any indication like "if db == true then return end."
if db then return end is the shorter way of doing that. If you added a 'not' (without quotes) after the if on line 6, it would basically stop the function if db was false, instead of stopping it when it's true.