Icon.MouseEnter:connect(function() while wait(0.1) do IconBorder.Rotation = IconBorder.Rotation + 5 end end) Icon.MouseLeave:connect(function() while wait(0.1) do IconBorder.Rotation = 0 end end)
When the Mouse Leaves, the rotation doesn't stop. Anyway to do this?
hello, ackalota !
I think I know why your script isn't working properly! This can be because when you starts a loop, it only stops when the var comes false(in this case, the var is "wait(0.1)"
this var can't never go to false, so the while will run infinitly
try adding something like debounce!
Tested (and working) example:
local mouseOut = false Icon.MouseEnter:connect(function() while mouseOut == false do wait(0.1) IconBorder.Rotation = IconBorder.Rotation + 5 end end) Icon.MouseLeave:connect(function() mouseOut = true wait(0.2) mouseOut = false IconBorder.Rotation = 0 end)
Don't forget to properly set the "Icon" and "IconBorder" variables!
-- For more information about Debounce, acess: http://wiki.roblox.com/index.php?title=Debounce
Good luck with your game!