# Tweening rotation from -90 to 0 rotates inefficiently

(i’ve just now noticed after finishing to write this post that i should have actually written an angle of -90 as 270, but i forgot thats how rotation for GUI’s actually work, so please keep in mind when you see -90 that i meant 270 lol)

I’ve just finished making a script for a radial menu (like in GTA’s weapons selection menu apparently) and have used TweenService to smoothly rotate a highlight across each option you hover over. The problem is, when the rotation begins at -90, and is tweened to 0, it would expectedly move clockwise, the quickest path to the goal. Instead, it moves anti-clockwise, and zips around the menu with a really jarring look in comparison to the expected behaviour. (same problem in this post)

I’ve annotated the angle for each segment thingy, and the grey arrow shows what is obviously EXPECTED to occur, however in actuality, for some reason it goes aaaaaall the way around like in the red arrow.

does anyone know a way to force tweenservice to move the right way in this specific scenario?
I am definitely not going to do something like partially/completely remake tweenservice as i wouldn’t even know where to begin, let alone how not to make it cook the users device, so any tips or ideas for how to make my existing system function would be appreciated

Alright, so I don’t really know if that would work but I have this function right here:

``````local function LookAtUI(O1:GuiObject,O2:GuiObject)
local dist = O1.Position-O2.Position
local vector = Vector2.new(dist.X,dist.Y).Unit
return math.deg(math.acos(vector.X))*math.sign(math.asin(vector.Y))
end
``````

You would need to set O1 to the object that you want to rotate and you would need to set O2 to the object that O1 will look to.

and then here you will do this:

``````local function LookAtUI(O1:GuiObject,O2:GuiObject)
local dist = O1.Position-O2.Position
local vector = Vector2.new(dist.X,dist.Y).Unit
return math.deg(math.acos(vector.X))*math.sign(math.asin(vector.Y))
end

local angle = LookAtUI(O1, O2)
local convertedRotation = part.Orientation.Y % 360

-- Here you will do the tweening and set the Goal to {["Rotation"] = convertedRotation}
``````

Hope this helps!!
Let me know if it doesn’t work. I haven’t tested it.

The problem is that Roblox can assign more than 360 in Rotation, instead of -90 write 270, and instead of 0 write 360 ​​and try again.

Example

``````local TweenService = game:GetService("TweenService")
local CurrentTweenActions = {}

local Button = script.Parent.Button -- Event
local Frame = script.Parent.Frame -- Object To Rotate

Button.MouseButton1Click:Connect(function()
local TweenAction = TweenService:Create(Frame, TweenInfo.new(.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
Rotation = 360
})

table.insert(CurrentTweenActions, TweenAction)

TweenAction:Play()

for _, CurrentAction in pairs(CurrentTweenActions) do
if CurrentAction.PlaybackState == Enum.PlaybackState.Playing then
return
end
end

CurrentTweenActions = {}

Frame.Rotation = 0
end)
``````

im not sure if you understood, i already have all the angles set up and getting them isnt the problem, however my issue is that tweening from an original angle of 270 means that when i set the goal as 0, the tween gets confused and sends the rotation the wrong way.