-- Переменные для координат спавна крипов local radiantSpawnPoint = Vector3.new(133.165,…
- User
-- Переменные для координат спавна крипов local radiantSpawnPoint = Vector3.new(133.165, 0.5, 47.051) local direSpawnPoint = Vector3.new(-132.107, 0.5, 43.742) local creepsattackrange = 8 local radiantModels = {} local direModels = {} local pathfindingService = game:GetService("PathfindingService")
local function checkForEnemyCreep(creep) for _, enemyCreep in ipairs(workspace:GetChildren()) do if enemyCreep.Name == "RadiantCreep" or enemyCreep.Name == "DireCreep" then if creep.Name:find("RadiantCreep") and enemyCreep.Name == "DireCreep" then if (enemyCreep.PrimaryPart.Position - creep.PrimaryPart.Position).Magnitude <= creepsattackrange and enemyCreep.Humanoid.Health > 0 then return true -- Если найден враждебный крип рядом, возвращаем true end elseif creep.Name:find("DireCreep") and enemyCreep.Name == "RadiantCreep" then if (enemyCreep.PrimaryPart.Position - creep.PrimaryPart.Position).Magnitude <= creepsattackrange and enemyCreep.Humanoid.Health > 0 then return true -- Если найден враждебный крип рядом, возвращаем true end end end end return false -- Если враждебных крипов рядом не найдено, возвращаем false end
local function startFight(attacker, target) while attacker.Humanoid.Health > 0 and target.Humanoid.Health > 0 do attacker.Humanoid:MoveTo(target.PrimaryPart.Position) wait(0.2)
codeif (attacker.PrimaryPart.Position - target.PrimaryPart.Position).Magnitude <= 1.5 then local damage = math.random(2, 6) target.Humanoid.Health = target.Humanoid.Health - damage else attacker.Humanoid:MoveTo(target.PrimaryPart.Position) end if attacker.Humanoid.Health > 0 and target.Humanoid.Health > 0 then local enemyCreepNearby = checkForEnemyCreep(attacker) if not enemyCreepNearby then target = nil -- Сброс цели, чтобы крип начал искать новую после каждой атаки break end end endend
local modelFolder = game.ServerStorage:WaitForChild("Creeps")
-- Получаем список моделей крипов и разделяем их по фракциям for _, model in ipairs(modelFolder:GetChildren()) do if model.Name:find("RadiantCreep") then table.insert(radiantModels, model) elseif model.Name:find("DireCreep") then table.insert(direModels, model) end end
local function spawnCreeps() -- Спавн радиантских крипов for _, model in ipairs(radiantModels) do local factionValue = Instance.new("StringValue") factionValue.Name = "Faction" factionValue.Value = "Radiant"
code - Assistant