Invalid argument #2 (Vector3 expected, got CFrame)

function TweenToPoint(destination, car)
	if Tycoon.PurchasedObjects:FindFirstChild(car) then
		local newCar = Tycoon.PurchasedObjects[car]
		local primary = newCar:FindFirstChild("Primary") or newCar.PrimaryPart
		
		local speed = (primary.CFrame - destination.CFrame).Magnitude -- Error Here
		
		local info = TweenInfo.new(speed, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
		local props = {CFrame = destination.CFrame}
		local tween = TS:Create(primary, info, props)
	
		tween:Play()
		tween.Completed:Wait()
	end
end

This is the function, (it gets called later in the script), and the output always says this: "invalid argument #2 (Vector3 expected, got CFrame)", and I can only imagine it’s because the “things” don’t exist, but they do.

Any help is appreciated, (also it’s very little info so i can say more if you want me to)

You cannot subtract CFrames.

1 Like

What should I put instead of putting CFrame, to get the speed?

Well, Since you are just getting the Distance, you might be able to do this:

(primary.Position - destination.Position).Magnitude

or:

(primary.CFrame.Position - destination.CFrame.Position).Magnitude
1 Like

Yes, that works perfectly! Thank you!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.