Yes, I already did this - the issue is mainly that there’s issues with the Tween after the mouse leaves (ether it keeps going, or it doesn’t start the next time the mouse enters the button).
You could nil the tween and then play the reverse when the MouseLeave event is fired. Something like in the following.
local tweens = game:GetService("Tweens")
local guiObject = script.Parent
local tween = nil
guiObject.MouseEnter:Connect(function()
if tween then
tween:Cancel()
tween = nil
end
tween = tweens:Create(guiObject, TweenInfo.new(1), {})
tween:Play()
end)
guiObject.MouseLeave:Connect(function()
if tween then
tween:Cancel()
tween = nil
end
tween = tweens:Create(guiObject, TweenInfo.new(1), {})
tween:Play()
end)
If you want a more dynamic tween then you could scale the time according to the “distance” from the goal properties table.
I don’t think you really understand the subject here, I don’t want it to tween one way when entered then another when left, I want it to rotate back and forth only while it’s being hovered over.
I’ve come up with a really bad solution to it and the post is resolved.
local tweens = game:GetService("TweenService")
local run = game:GetService("RunService")
local guiObject = script.Parent
local mouseIn
guiObject.MouseEnter:Connect(function()
mouseIn = true
while mouseIn do
run.RenderStepped:Wait()
local tween = tweens:Create(guiObject, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0), {Rotation = 180})
tween:Play()
tween.Completed:Wait()
end
end)
guiObject.MouseLeave:Connect(function()
mouseIn = false
end)
Relatively simple, there’s a parameter which represents whether or not the tween should reverse, all you need to do is have the tween repetitively play while the mouse is inside the GuiObject, once outside this loop should be stopped.