Make the camera rotate on the z axis but still able to rotate the camera freely

I have a spaceship seat that locks the player’s camera to first person. The spaceship can roll and rotate on the z axis. How can I rotate the camera according to the spaceship’s z axis but can still able to rotate the camera freely like an average first person? Thanks!

My guess would be to have a function run when the CFrame of the spaceship changes and make the CFrame of the camera have the same CFrame as what the spaceship has expect only taking the Z axis of it.

An example of what i mean would be:

local CurrentCamera = workspace.CurrentCamera

function Update_Camera()

	CurrentCamera.CFrame = CurrentCamera.CFrame *, 0, Spaceship.CFrame.Z) -- ## Change the Spaceship to whatever has the Z axis changing


Spaceship:GetPropertyChangedSignal("CFrame"):Connect(Update_Camera) -- ## Same here

Let me know if it works in any case, i have not tested this.

You must have a custom “scriptable” camera system already in place or else this won’t work.

Use CFrame.lookAt's 3rd parameter, called up. Set it to the ship’s UpVector/YVector. The lookAt parameter should be what is originally set.

1 Like