Invalid argument #1 when trying to put Vector3s in a Table

This is probably a common question, but I need to put Vector 3’s into a table and it gives me invalid argument #1 (number expected). I read other posts for help, but they don’t work in my use case. I tried making pos_1 & 2 as arrays but that didn’t work either. How do I make my Vector3s compatible?

Here is the script: (it’s quite unfinished in other areas as well so feel free to ignore those):

local AI = game:GetService("PathfindingService")
local zomhum = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")

pos_1 = script.Option_A
pos_2 = script.Option_B



local B = coroutine.create(function(B)
	
		local raycastResult_B = workspace:Raycast(torso.Position, torso.CFrame.RightVector * 99)
	print("cast 2...")
	while wait(3) do
		if raycastResult_B then
			local hitPart_B = raycastResult_B.Instance
			pos_2 = Vector3.new(hitPart_B.Position)
			if hitPart_B then
				print('b')
			else
				print ('no 2')
			end
		end
	end 
end)

local A = coroutine.create(function(A)
	local raycastResult_A = workspace:Raycast(torso.Position, torso.CFrame.LookVector * 99)
	print('casting...')
	if raycastResult_A then
		while wait(3) do
			local hitPart_A = raycastResult_A.Instance
			pos_1 = Vector3.new(hitPart_A.Position)
			
		if hitPart_A then
			print(hitPart_A.Position)
		else
			print ('no')
		end
	end
end end)



local function path_AI ()
	coroutine.resume(A)
	coroutine.resume(B)
	table.create(pos_1.Value, pos_2.Value)
end

while script.Parent.Humanoid.Health > 0 do
	path_AI()
end

hitPart_B.Position is already a Vector3, so the Vector3.new function errors.

1 Like

Rather than this:

pos_1 = Vector3.new(hitPart_A.Position)

Do this:

pos_1 = hitPart_A.Position
1 Like