Tweening angles with tween service

If I have an angle between 0 - 360 degrees as a variable, how can I go about using tween service to tween the angle using the shortest angular distance

What I’m currently doing is just creating a NumberValue and just tweening the value of that to whatever angle I need - this creates a problem, but let me first explain what I’m doing.

I’m creating a character movement system, I have a loop where the dinosaur constantly moves forward, and I can adjust the direction it moves in simply by adjusting this angle variable, and the move vector is set to the position in that unit circle corresponding to the current angle. It works pretty well for all intents and purposes.

However when I want to tween from one half of the circle to the other, from 0-180 to 180-360 and vice versa, the character rotates the long way round, as shown in the video. This only happens when you cross the 0/360 degree barrier.

https://gyazo.com/7671ce6823e133e3a072d0a823418482

It makes sense this would happen because if I was at say 2 degrees and wanted to go to 340 degrees, it’s going to go all the way up from 2 to 340 which is the longer path around.

I was wondering if there is an easy workaround to this problem that allows me to always tween the angle using the shortest path, so for the previous example, from 2 to 0/360 and then from 0/360 to 340 instead of 2 - 340.

you could do that with tween service

local TweenService = game:GetService("TweenService")
local model = blabla
local primaryPart = model.PrimaryPart
local speed = 1
local rotation = Vector3.new() -- put your rotation here

local tweenInfo = TweenInfo.new(speed, Enum.EasingStyle.YourEasingStyle, Enum.EasingDirection.YourEasingDirection, 0, false, 0)

local tween = TweenService:Create(primaryPart, tweenInfo, {Orientation = rotation})

tween:Play() -- Put this line wherever you like.