Locking Camera Behind Player

I am trying to lock the camera behind the player so that they cannot move it, but can’t seem to figure out how this would be achieved. If somebody could help me figure it out, that would be great :slight_smile:

I want the camera to be locked like this so that the player cannot move it at all;

Sorry if this is answered somewhere else, but all I can find is locking the camera to one specific part

do you want the camera distance from the player to update as they move down the area?

Unsure what you mean by this. Yes, I want the camera to follow the player if that’s what you’re asking.

I am assuming this would go in a local script so it can get the camera, but would I put it in StarterCharacterScripts?

So should it go in StarterPlayerScripts? Where else should it go so it persists after death

starter player #30characterlimit

Hm… When I set the DIST_FROM_PLAYER value to 10 I get this;

When I set it to -10 I get this;

So I believe I have to set the distance to 10 (not the DIST_FROM_PLAYER, but the actual distance, so the DIST_FROM_PLAYER value would be -10) and somehow rotate the camera 180 degrees. I tried changing the first two values (seperately) to 180 and that didn’t work. Any ideas?

i noticed im gonna fix it up it i studio give me a few mins

Also, do you want the camera to rotate on the one axis when the right button is held down and moved?

Nope, the camera should not move at all.

then in the script you need to have a part where the camera should start and where it should face. You said in the post you want it locked behind the player, anyways here is the script i made it should give you some help:

--try using this in a local script
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local DIST_FROM_PLAYER = 10 -- decrease this to make the camera close and increase for vice versa

Camera.CameraType = Enum.CameraType.Scriptable
repeat RunService.Stepped:Wait() until Player.Character.PrimaryPart
RunService.RenderStepped:Connect(function()
   Camera.CFrame = CFrame.new(Character.PrimaryPart.CFrame.Position+(-Character.PrimaryPart.CFrame.LookVector*DIST_FROM_PLAYER),Character.PrimaryPart.CFrame.Position)
end)
2 Likes

Better, but how could I move the camera up. Currently it sits at the players’ feet…

Also how could I stop the camera from rotating when a or d are hit?

Edit: I see how you did it using the characters’ primary part, but this comes with it’s own set of problems that I just stated

Add an invisible part or something but you need to defined where you want the character to face, then fill in the line in this code: (IT has to be a part)

--try using this in a local script
local RunService = game:GetService("RunService")
local Part = --insert the part that you want the camera to face here
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local DIST_FROM_PLAYER = 10 -- decrease this to make the camera close and increase for vice versa
local HEIGHT = 2--increase or decrease to change the height from the ground
Camera.CameraType = Enum.CameraType.Scriptable
repeat RunService.Stepped:Wait() until Player.Character.PrimaryPart
RunService.RenderStepped:Connect(function()
   Camera.CFrame = CFrame.new(Character.PrimaryPart.CFrame.Position+(-Character.PrimaryPart.CFrame.LookVector*DIST_FROM_PLAYER),Part.Position)*CFrame.new(0,HEIGHT,0)
end)
5 Likes