How do I animate the rotation property of a Gui?
(Rotate the Gui)
You can use tween service:
local ts = game:GetService("TweenService")
local goal = {
Rotation = 90 — Change to end rotation
}
local info = TweenInfo.new() — Add desired time and easing direction/style
local tween = ts:Create(script.Parent, info, goal)
tween:Play()
Is there a way to speed it up?
This is my new code:
local ts = game:GetService("TweenService")
local goal = {
Rotation = -6
}
local goal2 = {
Rotation = 0
}
local info = TweenInfo.new(1)
local tween = ts:Create(script.Parent, info, goal)
local tween2 = ts:Create(script.Parent, info, goal2)
script.Parent.MouseEnter:Connect(function()
script.Parent.ImageColor3 = Color3.fromRGB(207,207,207)
tween:Play()
end)
script.Parent.MouseLeave:Connect(function()
script.Parent.ImageColor3 = Color3.fromRGB(255, 252, 252)
tween2:Play()
end)
Infinetly:
local TweenService = game:GetService("TweenService")
TweenService:Create(script.Parent --Or wherever it is located, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -0, false, 0), {{Rotation = 360}):Play()
Hopefully this helps you!
Change the one in TweenInfo.new()
That’s the duration
the first agrument on the tween info is the goal time
the lower value is faster
local TweenService = game:GetService("TweenService")
local TweenRotation = TweenService:Create(
script.Parent,
TweenInfo.new(
0.5, -- To Reach Goal --> LOWER VALUE IS FASTER
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0, -- Repeat Count
true -- Reverses
),
{
Rotation = -6
}
)
local function OnMouseEnter()
script.Parent.ImageColor3 = Color3.fromRGB(207,207,207)
TweenRotation:Play()
wait(TweenRotation.TweenInfo.Time)
TweenRotation:Pause()
end
local function OnMouseLeave()
script.Parent.ImageColor3 = Color3.fromRGB(255, 252, 252)
TweenRotation:Resume()
end
script.Parent.MouseEnter:Connect(OnMouseEnter)
script.Parent.MouseLeave:Connect(OnMouseEnter)