Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I fix "bad argument #2 to '?'" in this situation?

Asked by 4 years ago

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!

0
goto is the magnitude of the base and the building which is a number, not a vector. synkrio 281 — 4y
0
What is magnitude lol? PrismaticFruits 842 — 4y
1
goto is a number, it's expecting a vector3. royaltoe 5144 — 4y

Answer this question