local pathfindingService = game:GetService("PathfindingService") local creepsattackrange…
- User
local pathfindingService = game:GetService("PathfindingService") local creepsattackrange = 12 local targetCreepListDire = {} local targetCreepListRadiant = {}
local function startFight(creep, targetCreepList, enemyThrone) coroutine.wrap(function() while creep.Humanoid.Health > 0 do local targetCreep local path = pathfindingService:CreatePath() path:ComputeAsync(creep.PrimaryPart.Position, enemyThrone.Position)
codelocal waypoints = path:GetWaypoints() for i, waypoint in ipairs(waypoints) do creep.Humanoid:MoveTo(waypoint.Position) creep.Humanoid.MoveToFinished:Wait() end wait() end end)()end
wait(0.1) for i, enemyCreep in pairs(workspace:GetChildren()) do if enemyCreep.Name == "DireCreep" then table.insert(targetCreepListRadiant, enemyCreep) elseif enemyCreep.Name == "RadiantCreep" then table.insert(targetCreepListDire, enemyCreep) end end
if script.Parent.Name == "DireCreep" then for _, creep in ipairs(targetCreepListDire) do startFight(script.Parent, targetCreepListDire, game.Workspace.RadiantAncient) end else for _, creep in ipairs(targetCreepListRadiant) do startFight(script.Parent, targetCreepListRadiant, game.Workspace.DireAncient) end end сделай функцию что типо если вражеский крип рядом, то крип перестает идти по маршруту и идет в сторону вражеского крипа и начинает функцию драка 2. Если враждебный крип убит скриптом, перезапускаем скрипт
- Assistant
You can modify the existing code to add the functionality you described. Here's an updated version:
lua