"Position cannot be assigned to"

“Position cannot be assigned to” pops out, when I try to change position of player′s camera…

local UIS = game:GetService("UserInputService")
local Body = game.Workspace["DAF XF"].Body
local cam = workspace.Camera
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.One then
		cam.CameraType = Enum.CameraType.Custom
			while cam.CameraType == Enum.CameraType.Custom do
			wait()
			cam.CFrame.Position = Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z)
		end
	end
end)
2 Likes

What happens when you do

cam.Position = Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z)

Try doing cam.CFrame = CFrame.new(Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z))

Try editing the CFrame instead. To ensure it isn’t always facing one direction, make sure to multiply it by the current rotation

cam.CFrame = CFrame.new(Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z)) * cam.CFrame.Rotation
1 Like

You probably have a model or folder called Camera then, check that you don’t. Otherwise do workspace.CurrentCamera

Absolutly nothing happens…

Nope.
Snímka obrazovky 2023-08-24 111515

Do workspace.CurrentCamera, what happens?

Absolutly nothing…

local UIS = game:GetService("UserInputService")
local Body = game.Workspace["DAF XF"].Body
local cam = workspace.CurrentCamera
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.One then
		cam.CameraType = Enum.CameraType.Custom
			while cam.CameraType == Enum.CameraType.Custom do
			wait()
			cam.CFrame = CFrame.new(Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z)) * cam.CFrame.Rotation
		end
	end
end)

Write Camera.CFrame.Position and it should work

Camera.CFrame.Position = Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z

Try changing the camera type to be scriptable?

Snímka obrazovky 2023-08-24 111755

Well I still got the “Position Cannot be assigned to”

Try using the CFrame.new I suggested with the camera type as scriptable

Remove the CFrame.new(Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z) and write : Vector3.new(Body.Parent.DriveSeat.Position.X, Body.Parent.DriveSeat.Position.Y+5, Body.Parent.DriveSeat.Position.Z

Let′s say, after the @hya123456h reply, I edited it to this…

1 Like

Alright, and it should work. I don’t know if you’re showing a bug but you’re showing a bug uh… tell us.

Well, it didn′t work… It still showed the error and did nothing.

Pretty strange. Write local Cam = workspace.CurrentCamera instead of workspace.Camera