When I summon in the boss I want to summon in, it doesn’t seem to work and it’s AI just doesn’t work. However it responds with this:
BossLoader Script:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FX_Remotes = ReplicatedStorage:WaitForChild("FX_Remotes")
local BarRemote = FX_Remotes:WaitForChild("BossHealthBar")
local BossModule = require(script.Summoner)
local OnDeclarer = "START"
local OffDeclarer = "END"
local RANGE = 999999999999999
local Centre = workspace:WaitForChild("BossWaypoints"):WaitForChild("BossSpawn")
local function findTarget()
local players = game.Players:GetPlayers()
local maxDistance = RANGE
local nearestTarget
for i, player in pairs(players) do
if player.Character then
local target = player.Character
local distance = (Centre.Position - target.HumanoidRootPart.Position).Magnitude
if distance < maxDistance then
nearestTarget = target
maxDistance = distance
end
end
end
print("BOSS SYSTEM | Target Found!")
return nearestTarget
end
task.wait(30)
local PotentialPlayer = findTarget()
if PotentialPlayer then
local Player = Players:GetPlayerFromCharacter(PotentialPlayer)
local FirstBoss = BossModule.New("Inferal Incendiary")
BarRemote:FireClient(Player, "START", FirstBoss)
end
MainBossModule:
local PathfindingService = game:GetService("PathfindingService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local BossesStorage = ServerStorage:WaitForChild("Bosses")
local Debris = game:GetService("Debris")
local FX_Remotes = ReplicatedStorage:WaitForChild("FX_Remotes")
local Effects = workspace:WaitForChild("Effects")
local bosses = {}
function bosses.InfernalAI(InfernalIncendiary, Height)
local HRP = InfernalIncendiary:WaitForChild("HumanoidRootPart")
local BodyPosition = HRP:WaitForChild("BodyPosition")
local Humanoid = InfernalIncendiary:WaitForChild("Humanoid")
local SoundLibrary = workspace:WaitForChild("Sounds"):WaitForChild("Infernal")
BodyPosition.Position = HRP.Position + Vector3.new(0, Height, 0) + Vector3.new(0, math.random(-1.5,1.5), 0)
local Waypoints = workspace:WaitForChild("BossWaypoints")
local InfernalAnimations = script:WaitForChild("Infernal")
local Track_IDLE = InfernalAnimations:WaitForChild("Idle")
local Track_CHARGE = InfernalAnimations:WaitForChild("Charge")
local Track_CHARGE_FINISH = InfernalAnimations:WaitForChild("ChargeFinish")
local IdleAnimation = Humanoid:LoadAnimation(Track_IDLE)
local ChargeAnimation = Humanoid:LoadAnimation(Track_CHARGE)
local ChargeFinishAnimation = Humanoid:LoadAnimation(Track_CHARGE_FINISH)
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = {InfernalIncendiary}
local pathParams = {
AgentHeight = 5,
AgentRadius = 3,
AgentCanJump = true,
}
local lastPos
local RANGE = math.huge
IdleAnimation:Play()
local function FaceTarget(target)
InfernalIncendiary:SetPrimaryPartCFrame(CFrame.lookAt(HRP.Position, target.HumanoidRootPart.Position * Vector3.new(1, 0, 1) + target.HumanoidRootPart.Position * Vector3.new(0, 1, 0)))
end
local function canSeeTarget(target)
local orgin = HRP.Position
local direction = (target.HumanoidRootPart.Position - HRP.Position).Unit * RANGE
local ray = workspace:Raycast(orgin, direction, rayParams)
if ray and ray.Instance then
if ray.Instance:IsDescendantOf(target) then
print("BOSS SYSTEM | Can see target!")
FaceTarget(target)
return true
else
return false
end
else
return false
end
end
local function findTarget()
local players = game.Players:GetPlayers()
local maxDistance = RANGE
local nearestTarget
for i, player in pairs(players) do
if player.Character then
local target = player.Character
local distance = (HRP.Position - target.HumanoidRootPart.Position).Magnitude
if distance < maxDistance and canSeeTarget(target) then
nearestTarget = target
maxDistance = distance
end
end
end
print("BOSS SYSTEM | Target Found!")
return nearestTarget
end
local function getPath(destination)
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(HRP.Position, destination.Position)
return path
end
local function Charge(target)
local distance = (HRP.Position - target.HumanoidRootPart.Position).Magnitude
local debounce = false
if distance < 350 then
BodyPosition.Position = target.HumanoidRootPart.Position + Vector3.new(0, 5, 0)
SoundLibrary.Dash:Play()
IdleAnimation:Stop()
ChargeAnimation:Play()
task.wait(SoundLibrary.Dash.TimeLength + 0.1)
ChargeAnimation:Stop()
ChargeFinishAnimation:Play()
task.wait(0.15)
IdleAnimation:Play()
end
end
local function walkTo(destination)
local path = getPath(destination)
print("BOSS SYSTEM | Patrolling..")
if path.Status == Enum.PathStatus.Success then
for i, waypoint in pairs(path:GetWaypoints()) do
path.Blocked:Connect(function()
path:Destroy()
end)
local target = findTarget()
if target and target.Humanoid.Health > 0 then
print("BOSS SYSTEM | Target Found:" .. target.Name)
lastPos = target.HumanoidRootPart.Position
Charge(target)
break
else
if lastPos then
BodyPosition.Position = lastPos
task.wait(1)
lastPos = nil
break
else
BodyPosition.Position = waypoint.Position
task.wait(1)
end
end
end
else
return
end
end
local function patrol()
local waypoints = Waypoints:GetChildren()
local randomNum = math.random(1, #waypoints)
walkTo(waypoints[randomNum])
end
task.spawn(function()
while task.wait(0.2) do
patrol()
end
end)
Humanoid.Died:Connect(function()
local target = findTarget()
if target and target.Humanoid.Health > 0 then
local Player = game:GetService("Players"):GetPlayerFromCharacter(target)
FX_Remotes:WaitForChild("BossHealthBar"):FireClient(Player,"END", InfernalIncendiary)
task.wait(0.15)
InfernalIncendiary:Destroy()
end
end)
end
function bosses.New(Boss)
if BossesStorage:FindFirstChild(Boss) then
local SummonedBoss = BossesStorage:FindFirstChild(Boss):Clone()
SummonedBoss.Parent = workspace:WaitForChild("Bosses")
SummonedBoss:MoveTo(workspace:WaitForChild("BossWaypoints").BossSpawn.Position)
if SummonedBoss.Name == "Inferal Incendiary" then
bosses.InfernalAI(SummonedBoss, 50)
end
return SummonedBoss
end
end
return bosses