After a while, I just figured out how to fix the spinning compass after it reaches 360 degrees.
Here is the updated script for those who are curious about how I fixed it.
local plr = script.Parent.Parent.Parent.Name
local TweenService = game:GetService("TweenService")
local ang = 0
local previousAngle = 0
local current
local prevAngle = 0
local AddTo
while wait() do
local look = game.Workspace.Camera.CFrame.LookVector
local angle = math.atan2(look.X, look.Z)
if angle ~= previousAngle then
local Degrees = script.Parent.Degrees
previousAngle = angle
ang = -math.deg(angle) % 360
current = ang
AddTo = current - prevAngle
if AddTo <= -100 then
AddTo = AddTo / -100
end
if AddTo >= 300 then
AddTo = AddTo / 100
end
Degrees.Value = Degrees.Value + AddTo
prevAngle = ang
local goal = {}
goal.Rotation = Degrees.Value
local tweenInfo = TweenInfo.new(0.6)
local tween = TweenService:Create(script.Parent.ImageLabel, tweenInfo, goal)
tween:Play()
script.Parent.TextLabel.Text = math.floor(ang)
end
end
Thanks to those who replied.