Fixed Camera that rotates slightly when the player moves

Hey. Like the title says, I’m trying to make a Camera that is fixed onto a part, which rotates up/down/left/right depending on where the player moves. Its kinda hard to explain, but basically my game will be set in multiple rooms, where the Camera will be fixed outside the room, the black part being an example of the first rooms camera position. However, I don’t just want the Camera to be in a static position, I want it to be where the black part is, but pan slightly to the left if the player were to move to the left, pan slightly right if the player were to move to the right, and slightly up if the player were to jump for example. It just needs to be set to that one location, while being able to pan in a direction where the players location is.

You can make the camera look at the player by using CFrame.lookat()
example code

local cameraCF = CFrame.lookat(camera.CFrame.Position, player.Character.Head.Position)
camera.CFrame = cameraCF

You could then connect this to a RunService.RenderStepped event and update the camera orientation each frame. You could also add a lerp to give the camera a more gradual feel to its movement.

camera.CFrame = camera.CFrame:Lerp(cameraCF, 0.4) -- replace original camera set with this

Make sure to include a variable to disable the loop when needed say when tweening the camera to another room


Thank you! This will help a ton for my game!