-- slash1

Attack(target,structureDamage)
end
wait(.3)
end
end

else
if not enRoute then
wait(math.random(1,4))
if not target then
ScanForPoint()
end
end

end

wait()
end -- end of loop
end)
movementCoroutine()

local scanCoroutine = coroutine.wrap(function()
while task.wait(3) do
local nearestPlayer,closestPlayerDist = nil,60
local nearestBuilding,closestBuildingDist = nil, 100

for _,player in next,game.Players:GetPlayers() do
if player.Character and player.Character:IsDescendantOf(workspace) then
local pos = player.Character.PrimaryPart.Position
local dist = (root.Position-pos).magnitude
if dist < closestPlayerDist then
nearestPlayer = player
closestPlayerDist = dist
end
end
game:GetService("RunService").Heartbeat:wait()
end

local structures = _G.worldStructures
for building,buildingData in next,structures do
local dist = (building.PrimaryPart.Position-root.Position).magnitude
if dist < closestBuildingDist then
nearestBuilding = building
closestBuildingDist = dist
end
game:GetService("RunService").Heartbeat:wait()
end

if nearestPlayer and nearestBuilding then