Hi, so when a person’s mouse enters the button, it is supposed to be “shaking”.
I accomplish this by using math.random to get a random rotation. Then I tween the rotation of the button to that random number.
The problem with this is I want it to stop when the person’s mouse leaves. It is not doing that.
It keeps on shaking even though I don’t want it to. Can someone help?
script.Parent.MouseEnter:Connect(function(pos)
while script.Parent.MouseEnter do
task.wait()
local randomrot = math.random(0, 10)
local rotti = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local rottween = ts:Create(script.Parent, rotti, {Rotation = randomrot})
rottween:Play()
rottween.Completed:Wait()
end
end)
script.Parent.MouseLeave:Connect(function(pos)
local rotti = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local rottween = ts:Create(script.Parent, rotti, {Rotation = 5})
rottween:Play()
end)