Argument #1 Invalid, needs a CFrame?

You can write your topic however you want, but you need to answer these questions:
I’m checking if a parking space is free by checking the general location for any parts that are obstructing it. However, the check returns an error, as CFrame is expected instead of Vector3.new. However, CFrame is the only argument provided. What is going on?


for i,v in ipairs(collectionservice:GetTagged('Parking')) do
	if v:GetAttribute('Team') == player.TeamColor and not workspace:GetPartBoundsInBox(v.CFrame, v.Size + CFrame.new(0,20,0)) then
		print("no parts there found and team looks about right, let's do it!")
					
			parkingspace = v
		end
	end
			
	local carclone = car:Clone()
	carclone:PivotTo(parkingspace.CFrame + CFrame.new(0,10,0))

Thank you for any help.
Additionally, I sometimes get the error that the Vector 3 wasn’t able to be cast to Coordinate Frame on the last line.

1 Like

CFrame.new(0,10,0) is incorrect syntax, you need a vector3, not 3 numbers, do this:

CFrame.new(Vector3.new(0,10,0))
2 Likes

Thank you! However, the issue of argument 1 being invalid in workspace:GetPartBoundsInBox(v.CFrame, v.Size + CFrame.new(Vector3.new(0,20,0))) is still causing issues for me. It says v.CFrame is not a valid argument, as it is a Vector3 and it is expecting a CFrame.

1 Like

CFrame doesn’t allow adding to another CFrame. If you want to apply an offset relative to the first CFrame, you would need to do cframe * otherCFrame, if you want to apply an offset in world coordinates you would add using a Vector3 (so cframe + vector3)

And in the case of GetPartBoundsInBox, for the size param, you would do part.Size + Vector3.new(0, 20, 0) since adding a Vector3 to a CFrame will produce a CFrame, not a Vector3

2 Likes

Argument #1 is invalid. Argument #2 calls for a Vector3, which is provided properly through v.Size. My main issue comes from the CFrame not being accepted.
image

Aye, I’ve got it to work. Thanks all.

1 Like

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