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

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

Asked by
Prioxis 673 Moderation Voter
10 years ago

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

Log in to vote
1
Answered by
MrFlimsy 345 Moderation Voter
10 years ago

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)
Ad

Answer this question