Code:

while wait() do
	local buildings = {}
	local goto = nil
	for _,v in pairs(workspace.Base:GetChildren()) do
		if v:FindFirstChild("isBuilding") then
			table.insert(buildings, 1, (script.Parent.base.Position - v.isBuilding.Position).magnitude)
		end
	end
	table.sort(buildings)
	goto = buildings[1]
	buildings = {}
	script.Parent.base.CFrame = CFrame.fromAxisAngle(Vector3.new(script.Parent.base.Position), (goto - math.random(-0.2, 0.2)))
	script.Parent.base.BodyVelocity.Velocity = script.Parent.base.Orientation
	repeat wait() until (script.Parent.base.Position - goto).magnitude < 7
	script.Parent.base.CFrame = CFrame.fromAxisAngle(Vector3.new(script.Parent.base.Position), goto)
	while wait() do
		wait(1)
		local pew = Instance.new("Part")
		pew.Anchored, pew.CanCollide, pew.Transparency = true, false, 0.1
		pew.BrickColor = BrickColor.new("Gold")
		pew.Size = Vector3.new(0.1, 0.1, goto)
		pew.CFrame = CFrame.new(script.Parent.animated.raycastpart, goto) * CFrame.new(0, 0, -goto/2)
		pew.Material = Enum.Material.Neon
		pew.Parent = workspace.bulletContainer
		game.Debris:AddItem(pew, 0.1)
	end
end

Error: Workspace.rifleman.rifleman_AI:14: bad argument #2 to '?' (Vector3 expected, got number)

If anybody can help, that would be great!

3 comments

0

goto is the magnitude of the base and the building which is a number, not a vector.

0

What is magnitude lol?

1

goto is a number, it's expecting a vector3.