Can you guys check why my script wont work? The soldiers are supposed to kill and chase anyone near them that isn’t tagged. The problem is they won’t move.
local RomanRoot = script.Parent.HumanoidRootPart
local RomanHumanoid = script.Parent.Humanoid
local ss = game:GetService("ServerStorage")
local collectionService = game:GetService("CollectionService")
local function findenemy()
local aggro = 6000
local target = nil
local dmgrange = 7
for i, v in pairs(game.Workspace:GetChildren()) do
if collectionService:HasTag(v.Parent, "Iskandar") then
return
else
local human = v:FindFirstChild("Humanoid")
local root = v:FindFirstChild("HumanoidRootPart")
if human and root and v ~= script.Parent then
if v.Name ~= "Soldier" then
if (RomanRoot.Position - root.Position).Magnitude < aggro then
aggro = (RomanRoot.Position - root.Position).Magnitude
target = root
if (RomanRoot.Position - root.Position).Magnitude <= dmgrange then
human.Health = human.Health - 15
end
end
end
end
return target
end
end
end
while true do
wait()
local torso = findenemy()
if torso then
RomanHumanoid:MoveTo(torso.Position)
end
end