Hello! It’s been a while since I last posted in this topic.
So, recently I have been attempting to make a rotating GUI, but I just cant find a way to make it rotate smoothly. Yes, I have already tried:
while true do
wait(0.001)
Frame.Rotation = Frame.Rotation + -1
But honestly, it isn’t smooth at all. Plus, it infinitely rotates. I know I can use:
script:Destroy()
But even then, its just so annoying. Is there any other way? Thanks! <3
Edit: A lot of you know I kind of suck at scripting, and this would be a literal BREEZE for some of you. I’m not as advanced as the community, but I have been training to!
-- This code creates a tween (animation) that rotates the GUI object by 10 degrees over a duration of 10 seconds using a linear easing style.
local TweenService = game:getservice("TweenService") -- The TweenService is a service provided by Roblox that allows developers to create and control tweens.
local Gui = script.Parent
local tweeninfo = TweenInfo.new(10, Enum.EasingStyle.Linear) -- TweenInfo is a class that allows developers to specify the properties of a tween, such as its duration, easing style, and repeat behavior.
-- In this case, a TweenInfo object is created with a duration of 10 seconds and a linear easing style.
local Goal = 10 -- The goal of the tween is to rotate the GUI object by 10 degrees.
local Tween = TweenService:Create(Gui, tweeninfo, {Rotation=Goal}) -- A Tween object is then created using the TweenService, the GUI object, the TweenInfo object, and a table of properties to animate (in this case, just the Rotation property).
Tween:Play() -- Finally, the Tween:Play() method is called to start the tween.
I’ve typed this without testing it so just fix some issues. I’ve added comments so you know what everything does.
It worked! I knew it was something to do with TweenService, but I just couldn’t picture the script. Just quickly noting, where you were getting the service,
game:getservice("TweenService")
The “getservice” part wasn’t capitalized, which I just did a quick fix on this. Not trying to be rude, just stating. But anyways, thank you so much cookie!