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

Difficulties with making a bot?

Asked by 6 years ago
Edited 6 years ago

I'm trying to make a bot that can walk on land to expand it's territory (for my game) and fight players at the same time, it does work, but it has some flaws:

  • It sometimes ignores land that is surrounded by bot's land, making empty spots.
  • It only goes on the nearest land (e.g: It goes on islands then going to land near the island. Making exclaves.)
function findNearestTorso(pos)
    local list = game.Workspace:children()
    local torso = nil
    local dist = math.random(math.random(10,20),math.random(75,100))
    local temp = nil
    local human = nil
    local human2 = nil
    local temp2 = nil
    for x = 1, #list do
        temp2 = list[x]
        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
            local c = temp2:GetChildren()
            for i=1,#c do
                if (c[i]:IsA("Part")) and ((c[i].Position - pos).magnitude < dist) and (c[i].Name == "Land") and (c[i].BrickColor ~= tc.Value) then
                    torso = c[i]
                    dist = (c[i].Position - pos).magnitude
                end
            end
        end
    end
    return torso
end

Answer this question