How to rotate the camera (like actually)

There’s thousands of posts with different solutions that don’t even work most of the times about how to rotate the camera, all I want to do is to be able to run a small portion of code so that I can rotate the camera and turn a set amount of degrees and look left from looking forward or any direction. Would be nice if anyone had a straightforward solution.

Something like the following sequence of images

Here’s a quick and ugly code I wrote which makes you look back and forth whenever you set an attribute in the character. As an example, I did this whenever I jumped.

[robloxapp-20240907-2150192.wmv|attachment](upload://dpeRMeneKVy7hqxIL75cLS1w2Gy.wmv) (794.1 KB)

wait(0.1)

workspace.Gravity = 50 


ch = script.Parent
ts = game:GetService("TweenService")

ch:SetAttribute("Look",false)

cv = Instance.new("CFrameValue")
chH = ch:FindFirstChildWhichIsA("Humanoid")
c = workspace.CurrentCamera

chH.UseJumpPower = false
chH.JumpHeight	= 25

T = math.sqrt(1/2*chH.JumpHeight/workspace.Gravity) 

local i = CFrame.identity

cv.Changed:Connect(function(value: CFrame)  
	c.CFrame = c.CFrame * value * i:Inverse()
	i = value 
end)

ti = TweenInfo.new(T,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,true)

local T = ts:Create(cv,ti,{["Value"] = CFrame.Angles(0,math.pi/4,0) })
local S = ts:Create(cv,ti,{["Value"] = CFrame.Angles(0,-math.pi/4,0) })

local active	= false 

ch:GetAttributeChangedSignal("Look"):Connect(function(...: any)  
	
	if ch:GetAttribute("Look") and not active then
		active	= true 
	
		T:Play()
		T.Completed:Wait()
		S:Play()	
		S.Completed:Wait()
		ch:SetAttribute("Look",false)
		
		cv.Value = CFrame.identity
				
		active = false 
	end
	
end)


chH.Jumping:Connect(function(active: boolean)  
	if active == false then 
		ch:SetAttribute("Look",true)
	end 	
end)
1 Like

I tried it but I want it to be a single movement, without interpolation or anything. It’s really confusing too

1 Like