local rotatingHead = script.Parent
local speed = 0.5 -- how fast the camera rotates
local maxAngle = 45 -- max rotation in degrees
local angle = 0
local direction = 1
local baseCFrame = rotatingHead.CFrame
game:GetService("RunService").Heartbeat:Connect(function(dt)
angle += direction * speed
if math.abs(angle) > maxAngle then
direction *= -1
end
-- Rotate around Y axis
local rotation = CFrame.Angles(0, math.rad(angle), 0)
rotatingHead.CFrame = baseCFrame * rotation
end)