Problem with adding vector3 to cframe

Hello Deforum so I made this inspect item system and a zoom I added a zoom feature to it here’s my code for that;

local function Item_Zoom(direction)
				local Distance = 1.5
				if direction then
					if tempSelectedModel:GetPrimaryPartCFrame().Z >= Distance then
						return
					else
						tempSelectedModel:SetPrimaryPartCFrame(tempSelectedModel:GetPrimaryPartCFrame() + Vector3.new(0,0,0.01))
					end
				else
					if tempSelectedModel:GetPrimaryPartCFrame().Z <= -Distance then
						return
					else
						tempSelectedModel:SetPrimaryPartCFrame(tempSelectedModel:GetPrimaryPartCFrame() - Vector3.new(0,0,0.01))
					end
				end
			end
mouse.WheelForward:Connect(function()
if isBeingInspected then
		Item_Zoom(false)
	end
end)

mouse.WheelBackward:Connect(function()
	if isBeingInspected then
		Item_Zoom(true)
	end
end)

The problem is when I exit out of the inspect item system inspect the item again if I keep repeating this the tempSelectedModel:SetPrimaryPartCFrame(tempSelectedModel:GetPrimaryPartCFrame() + Vector3.new(0,0,0.01) will start adding a higher increment for some reason so instead of Vector3.new(0,0,0.01) it will be like Vector3.new(0,0,0.2) or something for some reason and I don’t know why if you need by cancel code I can show that to.

1 Like

Add a Vector3 to a CFrame like this:

tempSelectedModel:SetPrimaryPartCFrame(tempSelectedModel:GetPrimaryPartCFrame() + CFrame.new(0,0,0.01)

After all, the first 3 parameters of CFrame is a Vector3 value

I get an error when running this;
tempSelectedModel:SetPrimaryPartCFrame(tempSelectedModel:GetPrimaryPartCFrame() + CFrame.new(0,0,0.01))
it says vector 3 expected.