local Q=game:GetService("\080\108\097\121\101\114\115")local h=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")return function(N,H)local O=N.Parent local U=O:WaitForChild("\071\114\111\117\110\100")local T,J=N:WaitForChild("\072\117\109\097\110\111\105\100"),N:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")T.MaxHealth=2000 T.Health=2000 local t=Instance.new("\065\110\105\109\097\116\105\111\110")t.AnimationId="\114\098\120\097\115\115\101\116\105\100\058\047\047\053\048\055\055\054\054\051\056\056"local P=T:LoadAnimation(t)P:Play()P.Stopped:Connect(function()P:Play()end);(coroutine.wrap(function()while T.Health>0 and O.Parent do wait(3)if T.Health==0 then return end local O,t=math.huge,nil for Q,h in pairs(H)do local N=h.Character if N then local Q=N:FindFirstChild("\072\117\109\097\110\111\105\100")local h=N:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if Q and(Q.Health>0 and h)then local Q=(Vector2.new(J.Position.X,J.Position.Z)-Vector2.new(h.Position.X,h.Position.Z)).Magnitude if Q<O then O=Q t=h end end end end if t and O<300 then if O>50 then local h=Instance.new("\080\097\114\116")h.Size=Vector3.new(1,1,1)h.CFrame=J.CFrame h.CanCollide=false h.Parent=N local H=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")H.MeshType=Enum.MeshType.FileMesh H.Scale=Vector3.new(2,2,2)H.TextureId="\114\098\120\097\115\115\101\116\105\100\058\047\047\051\055\054\048\054\056\049\052"H.MeshId="\114\098\120\097\115\115\101\116\105\100\058\047\047\051\055\050\050\051\055\056\055"H.Parent=h local O=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")O.MaxForce=Vector3.new(math.huge,math.huge,math.huge)O.Velocity=(CFrame.new(J.CFrame.Position,t.Position)).LookVector*200 O.Parent=h h.Touched:Connect(function(N)local H=N.Parent if H and Q:GetPlayerFromCharacter(H)then local Q=H:FindFirstChild("\072\117\109\097\110\111\105\100")if Q then Q:TakeDamage(10)h:Destroy()end end end)delay(3,function()h:Destroy()end)elseif O<10 then local Q=Instance.new("\080\097\114\116")Q.Transparency=.25 Q.Material=Enum.Material.Neon Q.BrickColor=BrickColor.new("\066\114\105\103\104\116 \098\108\117\101")Q.Anchored=true Q.CanCollide=false Q.Size=Vector3.new(1,1,1)Q.CFrame=J.CFrame Q.Shape=Enum.PartType.Ball Q.Parent=N;(h:Create(Q,TweenInfo.new(1),{Size=Vector3.new(20,20,20);Transparency=1})):Play()delay(1,function()Q:Destroy()end)for Q,h in pairs(H)do local N=h.Character if N then local Q=N:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if Q then local h=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")h.MaxForce=Vector3.new(math.huge,0,math.huge)h.Velocity=(CFrame.new(J.Position,Q.Position)).LookVector*100 h.Parent=Q delay(.5,function()h:Destroy()end)end end end else local H={}local T=CFrame.new(J.Position,Vector3.new(t.Position.X,J.Position.Y,t.Position.Z))if math.random()>.5 then for Q=math.rad(20),math.pi*2,math.rad(20)do table.insert(H,((T*CFrame.Angles(0,Q,0))*CFrame.new(0,0,O)).Position)end else for Q=math.pi*.33333333333333,math.pi*2,math.pi*.33333333333333 do for h=1,10,1 do table.insert(H,((T*CFrame.Angles(0,Q,0))*CFrame.new(0,0,h*11)).Position)end end end local P=U.Position.Y+U.Size.Y/2 for H,O in pairs(H)do local U=Instance.new("\080\097\114\116")U.Transparency=.25 U.Material=Enum.Material.Neon U.BrickColor=BrickColor.new("\066\114\105\103\104\116 \114\101\100")U.Anchored=true U.CanCollide=false U.Size=Vector3.new(.2,10,10)U.CFrame=CFrame.new(O.X,P,O.Z)*CFrame.Angles(0,0,math.pi/2)U.Shape=Enum.PartType.Cylinder U.Parent=N delay(1,function()local H=Instance.new("\080\097\114\116")H.Anchored=true H.Size=Vector3.new(4,6,4)H.CFrame=CFrame.new(O.X,P-3,O.Z)H.Parent=N local T=Instance.new("\083\112\101\099\105\097\108\077\101\115\104")T.MeshId="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\048\051\051\055\049\052"T.TextureId="\114\098\120\097\115\115\101\116\105\100\058\047\047\051\057\050\053\049\054\055\054"T.Scale=Vector3.new(2,8,2)T.Parent=H local J={}H.Touched:Connect(function(h)local N=h.Parent if N and Q:GetPlayerFromCharacter(N)then local Q=N:FindFirstChild("\072\117\109\097\110\111\105\100")local h=N:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if Q and(h and not J[Q])then J[Q]=true Q:TakeDamage(10)local N=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")N.MaxForce=Vector3.new(0,math.huge,0)N.Velocity=Vector3.new(0,200,0)N.Parent=h delay(.25,function()N:Destroy()end)end end end);(h:Create(H,TweenInfo.new(.2),{CFrame=CFrame.new(O.X,P+3,O.Z)})):Play()delay(.25,function()U:Destroy()H:Destroy()end)end)end end end end end))()end
--[[
TheNexusAvenger

Sets up Bloxhilda.
--]]

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")



return function(BloxhildaModel,DungeonPlayers)
    --Set up the health.
    local Dungeon = BloxhildaModel.Parent
    local DungeonGround = Dungeon:WaitForChild("Ground")
    local Humanoid,HumanoidRootPart = BloxhildaModel:WaitForChild("Humanoid"),BloxhildaModel:WaitForChild("HumanoidRootPart")
    Humanoid.MaxHealth = 2000
    Humanoid.Health = 2000

    --Play the idle animation.
    local IdleAnimation = Instance.new("Animation")
    IdleAnimation.AnimationId = "rbxassetid://507766388"
    local IdleTrack = Humanoid:LoadAnimation(IdleAnimation)
    IdleTrack:Play()

    IdleTrack.Stopped:Connect(function()
        IdleTrack:Play()
    end)

    --Set up the attacks.
    coroutine.wrap(function()
        while Humanoid.Health > 0 and Dungeon.Parent do
            --Wait to perform a new attack.
            wait(3)
            if Humanoid.Health == 0 then return end

            --Determine the distance to the closest player.
            local ClosestPlayerDistance,ClosestHumnaoidRootPart = math.huge,nil
            for _,Player in pairs(DungeonPlayers) do
                local Character = Player.Character
                if Character then
                    local CharacterHumanoid = Character:FindFirstChild("Humanoid")
                    local CharacterHumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
                    if CharacterHumanoid and CharacterHumanoid.Health > 0 and CharacterHumanoidRootPart then
                        local Distance = (Vector2.new(HumanoidRootPart.Position.X,HumanoidRootPart.Position.Z) - Vector2.new(CharacterHumanoidRootPart.Position.X,CharacterHumanoidRootPart.Position.Z)).Magnitude
                        if Distance < ClosestPlayerDistance then
                            ClosestPlayerDistance = Distance
                            ClosestHumnaoidRootPart = CharacterHumanoidRootPart
                        end
                    end
                end
            end

            if ClosestHumnaoidRootPart and ClosestPlayerDistance < 300 then
                --Perform an attack.
                if ClosestPlayerDistance > 50 then
                    --Performs a ranged attack.
                    local PumpkinProjectile = Instance.new("Part")
                    PumpkinProjectile.Size = Vector3.new(1,1,1)
                    PumpkinProjectile.CFrame = HumanoidRootPart.CFrame
                    PumpkinProjectile.CanCollide = false
                    PumpkinProjectile.Parent = BloxhildaModel
                    
                    local Mesh = Instance.new("SpecialMesh")
                    Mesh.MeshType = Enum.MeshType.FileMesh
                    Mesh.Scale = Vector3.new(2,2,2)
                    Mesh.TextureId = "rbxassetid://37606814"
                    Mesh.MeshId = "rbxassetid://37223787"
                    Mesh.Parent = PumpkinProjectile

                    local BodyVelocity = Instance.new("BodyVelocity")
                    BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
                    BodyVelocity.Velocity = CFrame.new(HumanoidRootPart.CFrame.Position,ClosestHumnaoidRootPart.Position).LookVector * 200
                    BodyVelocity.Parent = PumpkinProjectile

                    --Set up setting damaging players.
                    PumpkinProjectile.Touched:Connect(function(TouchPart)
                        local Character = TouchPart.Parent
                        if Character and Players:GetPlayerFromCharacter(Character) then
                            local CharacterHumanoid = Character:FindFirstChild("Humanoid")
                            if CharacterHumanoid then
                                CharacterHumanoid:TakeDamage(10)
                                PumpkinProjectile:Destroy()
                            end
                        end
                    end)

                    --Destroy the projectile.
                    delay(3,function()
                        PumpkinProjectile:Destroy()
                    end)
                elseif ClosestPlayerDistance < 10 then
                    --Display the animation.
                    local KnockbackPart = Instance.new("Part")
                    KnockbackPart.Transparency = 0.25
                    KnockbackPart.Material = Enum.Material.Neon
                    KnockbackPart.BrickColor = BrickColor.new("Bright blue")
                    KnockbackPart.Anchored = true
                    KnockbackPart.CanCollide = false
                    KnockbackPart.Size = Vector3.new(1,1,1)
                    KnockbackPart.CFrame = HumanoidRootPart.CFrame
                    KnockbackPart.Shape = Enum.PartType.Ball
                    KnockbackPart.Parent = BloxhildaModel
                    
                    TweenService:Create(KnockbackPart,TweenInfo.new(1),{
                        Size = Vector3.new(20,20,20),
                        Transparency = 1,
                    }):Play()
                    delay(1,function()
                        KnockbackPart:Destroy()
                    end)

                    --Knock back the players.
                    for _,Player in pairs(DungeonPlayers) do
                        local Character = Player.Character
                        if Character then
                            local CharacterHumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
                            if CharacterHumanoidRootPart then
                                local BodyVelocity = Instance.new("BodyVelocity")
                                BodyVelocity.MaxForce = Vector3.new(math.huge,0,math.huge)
                                BodyVelocity.Velocity = CFrame.new(HumanoidRootPart.Position,CharacterHumanoidRootPart.Position).LookVector * 100
                                BodyVelocity.Parent = CharacterHumanoidRootPart
                                delay(0.5,function()
                                    BodyVelocity:Destroy()
                                end)
                            end
                        end
                    end
                else
                    --Determine the spike locations.
                    local SpikeLocations = {}
                    local SpikeCenter = CFrame.new(HumanoidRootPart.Position,Vector3.new(ClosestHumnaoidRootPart.Position.X,HumanoidRootPart.Position.Y,ClosestHumnaoidRootPart.Position.Z))
                    if math.random() > 0.5 then
                        --Create a ring of spikes.
                        for Angle = math.rad(20),math.pi * 2,math.rad(20) do
                            table.insert(SpikeLocations,(SpikeCenter * CFrame.Angles(0,Angle,0) * CFrame.new(0,0,ClosestPlayerDistance)).Position)
                        end
                    else
                        --Create 6 lines of spikes.
                        for Angle = math.pi * (1/3),math.pi * 2,math.pi * (1/3) do
                            for i = 1,10 do
                                table.insert(SpikeLocations,(SpikeCenter * CFrame.Angles(0,Angle,0) * CFrame.new(0,0,i * 11)).Position)
                            end
                        end
                    end

                    --Create the spikes.
                    local YPosition = DungeonGround.Position.Y + (DungeonGround.Size.Y/2)
                    for _,Position in pairs(SpikeLocations) do
                        --Create the warning part.
                        local WarningPart = Instance.new("Part")
                        WarningPart.Transparency = 0.25
                        WarningPart.Material = Enum.Material.Neon
                        WarningPart.BrickColor = BrickColor.new("Bright red")
                        WarningPart.Anchored = true
                        WarningPart.CanCollide = false
                        WarningPart.Size = Vector3.new(0.2,10,10)
                        WarningPart.CFrame = CFrame.new(Position.X,YPosition,Position.Z) * CFrame.Angles(0,0,math.pi/2)
                        WarningPart.Shape = Enum.PartType.Cylinder
                        WarningPart.Parent = BloxhildaModel

                        delay(1,function()
                            --Create the spike.
                            local Spike = Instance.new("Part")
                            Spike.Anchored = true
                            Spike.Size = Vector3.new(4,6,4)
                            Spike.CFrame = CFrame.new(Position.X,YPosition - 3,Position.Z)
                            Spike.Parent = BloxhildaModel

                            local SpikeMesh = Instance.new("SpecialMesh")
                            SpikeMesh.MeshId    = "rbxassetid://1033714"
                            SpikeMesh.TextureId = "rbxassetid://39251676"
                            SpikeMesh.Scale = Vector3.new(2,8,2)
                            SpikeMesh.Parent = Spike

                            local CharactersHit = {}
                            Spike.Touched:Connect(function(TouchPart)
                                local Character = TouchPart.Parent
                                if Character and Players:GetPlayerFromCharacter(Character) then
                                    local CharacterHumanoid = Character:FindFirstChild("Humanoid")
                                    local CharacterHumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
                                    if CharacterHumanoid and CharacterHumanoidRootPart and not CharactersHit[CharacterHumanoid] then
                                        CharactersHit[CharacterHumanoid] = true

                                        --Damage the player.
                                        CharacterHumanoid:TakeDamage(10)

                                        --Launch the player into the air.
                                        local BodyVelocity = Instance.new("BodyVelocity")
                                        BodyVelocity.MaxForce = Vector3.new(0,math.huge,0)
                                        BodyVelocity.Velocity = Vector3.new(0,200,0)
                                        BodyVelocity.Parent = CharacterHumanoidRootPart
                                        delay(0.25,function()
                                            BodyVelocity:Destroy()
                                        end)
                                    end
                                end
                            end)

                            --Move the spike.
                            TweenService:Create(Spike,TweenInfo.new(0.2),{
                                CFrame = CFrame.new(Position.X,YPosition + 3,Position.Z)
                            }):Play()

                            --Clear the spike.
                            delay(0.25,function()
                                WarningPart:Destroy()
                                Spike:Destroy()
                            end)
                        end)
                    end
                end
            end
        end
    end)()
end