#npc is attacking each other

1 messages · Page 1 of 1 (latest)

tribal sail
#

this is follow script 👇

function findNearestTorso(pos)
    local list = game.Workspace:GetChildren()
    local torso = nil
    local dist = 10000
    local temp = nil
    local human = nil
    local temp2 = nil
    for x = 1, #list do
        temp2 = list[x]
        if (temp2.className == "Model") and (temp2 ~= script.Parent) then
            temp = temp2:findFirstChild("HumanoidRootPart")
            human = temp2:findFirstChild("Humanoid")
            if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
                if (temp.Position - pos).magnitude < dist then
                    torso = temp
                    dist = (temp.Position - pos).magnitude
                end
            end
        end
    end
    return torso
end

while true do
    wait(0.001)
    local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)
    if target ~= nil then
        script.Parent.Humanoid:MoveTo(target.Position, target)
    end

end

and this is swordActivate script👇

while true do script.Parent.ClassicSword:Activate() task.wait(2) end

help me fix this

dapper oak
thin turtleBOT
#

studio** You are now Level 3! **studio

tribal sail
tribal sail
tribal sail
#

i already fixed it

#

thanks to roblox ai

#

he helped me

dapper oak