How can I rotate the camera?

How can I rotate the camera? I want to make a tilt script, tilting left and right for dodging bullets, but I want the camera to rotate with the player. I tried workspace.CurrentCamera.Rotation, but this errored nil. What should I do?

6 Likes

Use LocalScript

and do

camera = workspace.CurrentCamera
camera.Cameratype = Enum.cameratype.Scriptable
camera.CFrame = camera.CFrame * CFrame.angles(math.rad(90),0,0)

basic example :slight_smile:

7 Likes

Oooh I forgot you had to make it scriptable my bad lol, thank you :smiley:

Just tried this, works how I explained, but not how I wanted. Heres a gif of what I mean

https://gyazo.com/737f4dfd67c368b5ade6f9df03e12144

See how when I tilt, my camera also tilts, how can I achieve this?

2 Likes
workspace.CurrentCamera.CFrame = CFrame.lookAt(cameraPosition, PositionOfObjectToLookAt)

Or you can create a part in the player character and move set the camera CFrame to that part cframe then use runservice:bindtorenderstep for updating it

1 Like

Wouldn’t this just point at an object? I don’t want it to point I want the camera to rotate

2 Likes

i think you should check with userinputservice when player clicks left arrow
and do something like

local ts = game:GetSerivice("TweenService")

local camera = workspace.CurrentCamera
camera.Cameratype = Enum.cameratype.Scriptable
local Tweeninfo = Tweeninfo.new(0.5) --time of tween
ts:Create(camera,info,{CFrame = camera.CFrame*CFrame.angles(0,0,math.rad(45))}):Play()
3 Likes