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

How do I make this part of the mouse enter script repeat?

I'm designing a shop GUI and I want the button to rotate infinitely when I mouse over it but when I tried to do certain things to make that happen nothing happened here's the script

function enter()
script.Parent.Rotation = script.Parent.Rotation +5
end

function leave()
script.Parent.Rotation = 0
end

script.Parent.MouseEnter:connect(enter)
script.Parent.MouseLeave:connect(leave)

1 answer

Use a loop.

local rotating = false

function enter()
    rotating = true
    while rotating == true do
        script.Parent.Rotation = script.Parent.Rotation +5
        wait(.1) --interval here
    end
end

function leave()
    rotating = false
    script.Parent.Rotation = 0
end

script.Parent.MouseEnter:connect(enter)
script.Parent.MouseLeave:connect(leave)

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