Why can't I assign position to CFrame?

Have a confusing script with the error

Position cannot be assigned to

How can I fix this?

Car.Kart.Touched:Connect(function(Part)
	if not Part.Parent:FindFirstChild("DriveSeat") then
		local NewCFrame = CFrame.new()
		NewCFrame.Position = Car:GetPivot().Position
		NewCFrame.Rotation = Car:GetPivot().Rotation
		
		Car:PivotTo(NewCFrame)
	end
end)

Thanks in advance!

All of the CFrame’s properties are read only, meaning you can’t set them. From what it looks like, you’re trying to set a Car’s CFrame to the CFrame it’s already at?

1 Like

Yes, that is correct for testing reasons, then I am going to change the rotation one to not be tilted.

Basically going to only want green once I have this system of teleporting the car in the same place to make it only set the green.
image

If you want to change the rotation, just do:

Car.Kart.Touched:Connect(function(Part)
	if not Part.Parent:FindFirstChild("DriveSeat") then
        -- this code rotates the car's cframe by 90 degrees on the y axis, which is the green ring
        -- you can change the numbers to anything you want, just remember that the numbers
        -- are in radians, so you will need to convert them using math.rad
		local NewCFrame = Car:GetPivot() * CFrame.Angles(0, math.rad(90), 0)

		Car:PivotTo(NewCFrame)
	end
end)