Invalid argument #1 (CFrame expected, got number)

I’m getting an error where it said CFrame expected even though it is CFrame?, I’m utterly and ultimately confused Help would be extremely appreciated thank you!

This is my script :

script.Parent.MouseEnter:Connect(function()
	local camera = Instance.new("Camera")
	camera.Parent = script.Parent
	fram1.CurrentCamera = camera
	local item1 = Items.SeaTea:Clone()

	local PCF1 = item1.CFrame - item1.CFrame.Position

	item1.CFrame = CFrame.new(0,0,item1.ZPosPreview.Value * PCF1)
	item1.Parent = fram1
	camera.FieldOfView = 2.5
	camera.CFrame = CFrame.new(item1.Position + (item1.CFrame.lookVector*5)+Vector3.new(0,0,90),item1.Position)
end)

Item1 is a part.

1 Like

Which line is the error on? It would help us solve the error.

item1.CFrame = CFrame.new(0,0,item1.ZPosPreview.Value * PCF1)

You are attempting to multiply a CFrame by a number which isn’t a supported operation. You haven’t explained what you are trying to do, but it seems as if you desire to apply rotation with default position except for your desired z-component, so this may work for you:

item1.CFrame = CFrame.new(0,0,item1.ZPosPreview.Value) * PCF1
4 Likes

Thank you this worked!, Awesome.