Issue assigning CFrame to camera using BindToRenderStep

Hello!

I am trying to have this camera locked on all axes but still follows the player around, however this isn’t happening. I am getting an error but I don’t know how to solve it.

Here’s my script (with bad indenting, sorry)

local CC = workspace.CurrentCamera

local HRP = workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild('HumanoidRootPart')

CC.CameraType = Enum.CameraType.Attach

local function bindCamera()

CC.CFrame.Position = Vector3.new(CC.CFrame.Position.X, 20, CC.CFrame.Position.Z)

end

game:GetService('RunService'):BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value + 1, bindCamera)

Here’s the error (yup, the sentence just cuts off like that lol)

RunService:fireRenderStepEarlyFunctions unexpected error while invoking callback: Position cannot be assigned to

1 Like

Same error.

RunService:fireRenderStepEarlyFunctions unexpected error while invoking callback: Position cannot be assigned to

Same error again. I am trying with both scriptable and attach.

Same thing on both camera types, this is driving me nuts lol, the output isn’t even saying what is wrong.

Oh, I only noticed on the CFrame.new. Let me try on CC.

Alright, it’s not erroring but it isn’t doing anything either.

It’s just meant to lock the orientation. The position should be able to move around freely.

My gosh, you are a life saver. Do you know how to make it so the camera just pans around isntead of rotating?

Yeah I caught that typo haha. It’s Euler, not Eulers btw, the To worked instead of From.

1 Like

Actually, it seems to not be working anymore. I am not sure why. Maybe I only checked two of the axes.

EulerAngles can have problems from time to time, see if this will fix it. Bear in mind I have no experience with BindToRenderstep and priorities with this sort of thing.

Cam1, Cam2, Cam3 = CC.CFrame.XVector, CC.CFrame.YVector, CC.CFrame.ZVector

local function bindCamera()
    CC.CFrame = CFrame.fromMatrix(CC.CFrame.Position, Cam1, Cam2, Cam3)
end
1 Like

Same thing, no erroring but the hole isn’t being followed properly attach, or at all with scriptable. Pretty much all I want to achieve right now is to follow the character, but the camera should be locked, unable to move unless the character is moving.

I GOT IT!

It was actually waaay easier than I thought, you just had to do this:

CC.CFrame = CFrame.new(Vector3.new(HRP.Position.X, HRP.Position.Y + 10, HRP.Position.Z + 20), HRP.Position)

There are obviously a few things to fix up, but that’s generally what I wanted. You also had to create a button to activate as it wouldn’t activate normally. Thank you guys for the help!