Camera Animation Not Working

  1. What do you want to achieve? I want for my camera to rotate like a real one

  2. What is the issue? Is it rotating not firstly 45 and then -90, but its just spinning

local tweenService = game:GetService("TweenService")

while true do
	local firstAngle = 45
	local secondAngle = -90
	tweenService:Create(script.Parent.Head.PrimaryPart, TweenInfo.new(7), {
		CFrame = script.Parent.Head.PrimaryPart.CFrame * CFrame.Angles(firstAngle,0,0)
	}):Play()
	tweenService:Create(script.Parent.Head.PrimaryPart, TweenInfo.new(7), {
		CFrame = script.Parent.Head.PrimaryPart.CFrame * CFrame.Angles(secondAngle,0,0)
	}):Play()
	wait(3)
end

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub? No
1 Like

Use a cylindrical constraint, it will make your life easier as you can just use your mouse to set the pivot point while adjusting the speed and direction in a script and the angles and other stuff in the properties on the constraint.

you have to use

math.rad(angle)

look here Why use math.rad() for CFrame.Angles? and other CFrame questions

1 Like

you dont have to use while true do bc you can make tween Reverses

local tweenInfo = TweenInfo.new(
	2, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	0 -- DelayTime
)
local tweenService = game:GetService("TweenService")

local model = script.Parent
local head = model.Head
local part = head.PrimaryPart

local tween

while true do
	tween = tweenService:Create(part, TweenInfo.new(7), {CFrame = part.CFrame * CFrame.Angles(math.rad(45), 0, 0)})
	tween:Play()
	tween.Completed:Wait()
	tween = tweenService:Create(part, TweenInfo.new(7), {CFrame = part.CFrame * CFrame.Angles(math.rad(-90), 0, 0)})
	tween:Play()
	tween.Completed:Wait()
end