I had a hard time following the documentation for CFrames. When I tried to implement a script to assign the player camera’s CFrame to a part’s (cam1/cam2) CFrame, it either comes up with “Position cannot be assigned to.” or “invalid argument #1 to ‘new’ (Vector3 expected, got CFrame)”.
if useCurrentCam then
local CF = CFrame.new(workspace.CurrentCamera.CFrame)
camera.CFrame = CF -- use player camera as cam1
else
local CF = CFrame.new(cam1.CFrame)
camera.CFrame.Position = CF -- use set camera as cam1
end
I’ve asked multiple people about this and apparently I’m just not getting it.
The code in question is contained in a Modulescript under StarterGui if that helps
CFrame.new() requires a vector3 to be used, you just need cam1.CFrame not to CFrame the existing cframe.
and like slav said you cannot set a cframes position like that.
if useCurrentCam then
local CF = CFrame.new(workspace.CurrentCamera.CFrame)
camera.CFrame = CF -- use player camera as cam1
else
camera.CFrame = cam1
end
this doesnt return an error but also doesnt set the value. ive been told elsewhere that this is because it changes the vector3 of camera.CFrame to (0, 0, 0), but I had it print the CFrame value and the value is correct, but the player’s camera doesn’t migrate to the new CFrame value.