Setting camera CFrame problem

Hi there!
Im trying to make my camera go to the players’ chest but when i set the cframe it comes up with this
image
The code being affected:

Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = game.Players.LocalPlayer.Character.Torso.CFrame.Position + CFrame.new(-1,1,1)

Any help would be appreciated :smiley:

so the problem with this script is that the game thinks you are trying to place the camera in a position but not giving it the orientation. Here’s how you can do this:

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(-1,1,1))

that is if you want to set it to the character’s torso without the orientation. if you are wanting the orientation this should be what you do:

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = player.Torso.CFrame * ((player.Torso.CFrame.LookVector * -1) * (player.Torso.CFrame.RightVector * 1) * (player.Torso.CFrame.UpVector * -1))

the way that this works is that you get the torso’s position and rotation from just the cframe value. then you can just set the camera’s position directly to that. the lookvector and right vector are local axis to the torso, so instead of adding it to like x in global space it’s directly to the right or forward.
I didn’t test this so idk if it works, just send a reply and let me know if it doesn’t

image
Still returns a similar error message

my fault, here’s the corrected script:

local player = game.Players.LocalPlayer
local char = player.Character
local Camera = workspace.CurrentCamera
local torso = char:WaitForChild("Torso")

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = torso.CFrame * CFrame.new(
	torso.CFrame.LookVector * -1,
	torso.CFrame.RightVector,
	torso.CFrame.UpVector * -1
)

just a note, this only places the camera at the player’s torso as soon as the game starts, it doesn’t keep it there. otherwise you can set the Humanoid.CameraSubject to the torso i believe.

Worked like a charm, thank you :+1:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.