I’m clueless on how to tween a model 360 degrees. Currently It’s tweening 180 degrees and just restarting the tween when it reaches 180 to re-create a spinning effect, but that’s not what I need.
Here is the script I’m using.
local ts = game:GetService("TweenService")
local model = workspace.Model.PrimaryPart
local info = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out,-1)
local properties = {CFrame = model.CFrame * CFrame.Angles(0,math.rad(180),0)}
local tween = ts:Create(model,info,properties)
tween:Play()
wait(5)
tween:Play()
Except for this to work it has to a minimum 3 separate tween goals. Since if you did 361 that would default to 1 degree. It’s a really annoying this to solve.
I would’ve tweened a NumberValue instead, then updating the part’s CFrame when the NumberValue changes due to the tween.
Assuming you have a NumberValue parented to your script, the code could be something like this:
local TweenService = game:GetService("TweenService")
local NumberValue = script:WaitForChild("Value")
local Rotation = 0
function Rotate360Degrees()
Rotation = Rotation + 360
TweenService:Create(NumberValue, TweenInfo.new(5), {Value = Rotation}):Play()
end
local LastRotation = 0
NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
Part.CFrame = Part.CFrame * CFrame.Angles(0, math.rad(-LastRotation + NumberValue.Value), 0) -- This negates the previous rotation applied to the part
LastRotation = NumberValue.Value
end)
Rotate360Degrees()
I don’t know what you’re trying to do this for, but I’d definitely use an animation instead if it was for the character to spin.
I wanted the tween to rotate 360 degrees at once. That didn’t work out because of the tween taking the path of the least resistance. Instead I rotated it 3 times 120 degrees and it worked. I think and hope there is a better way of doing this so, I’m going to leave this post open for future replies and solutions.
Late response, sorry, but I found a solution for the game logo situation.
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local function RotateGui()
for i = 1, 360, 3 do
i = TweenService:GetValue((i/360), Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
script.Parent.Rotation = i * 360
RunService.RenderStepped:Wait()
end
end
while true do
RotateGui()
end
Change the Enum.EasingStyle and EasingDirection to whatever you’d like, and to make it faster, increase the number 3 on line 4 (be sure that the number goes into 360 though)