HowToRoblox

BossHandler

May 18th, 2021 (edited)
1,303
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local boss = script.Parent.Parent.Parent
  2. local humanoid = boss:WaitForChild("Humanoid")
  3.  
  4.  
  5. local ts = game:GetService("TweenService")
  6. local ringTI = TweenInfo.new(8, Enum.EasingStyle.Quint, Enum.EasingDirection.In)
  7. local fadeTI = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
  8. local meteorTI = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
  9.  
  10.  
  11. local attacks = game.ServerStorage:WaitForChild("Attacks")
  12.  
  13. local attacksContainer = Instance.new("Folder", workspace)
  14.  
  15.  
  16. local health = 1000
  17.  
  18. humanoid.MaxHealth = health
  19. humanoid.Health = health
  20.  
  21. local bar = script.Parent.BarBackground:WaitForChild("Bar")
  22. local healthLabel = script.Parent.BarBackground:WaitForChild("HealthText")
  23.  
  24.  
  25. function healthChanged()
  26.  
  27.     local xScale = humanoid.Health / humanoid.MaxHealth
  28.  
  29.     bar:TweenSize(UDim2.new(xScale, 0, 1, 0), "InOut", "Quint", 0.3)
  30.     healthLabel.Text = humanoid.Health .. "/" .. health
  31. end
  32.  
  33. healthChanged()
  34.  
  35.  
  36. humanoid.HealthChanged:Connect(healthChanged)
  37.  
  38.  
  39. humanoid.Died:Connect(function()
  40.  
  41.     attacksContainer.Parent = game.ServerStorage
  42.  
  43.     for i, descendant in pairs(boss:GetDescendants()) do
  44.  
  45.         if descendant:IsA("BasePart") then
  46.  
  47.             ts:Create(descendant, fadeTI, {Transparency = 1}):Play()
  48.         end
  49.     end
  50.  
  51.     wait(1)
  52.     attacksContainer:Destroy()
  53.     boss:Destroy()
  54. end)
  55.  
  56.  
  57. while humanoid.Health > 0 do
  58.  
  59.  
  60.     repeat wait() until #game.Players:GetPlayers() > 0
  61.  
  62.  
  63.     local ring = attacks.RingAttack:Clone()
  64.     ring.Size = Vector3.new(0, 0, 0)
  65.     ring.Position = boss.HumanoidRootPart.Position - Vector3.new(0, humanoid.HipHeight*1.5, 0)
  66.  
  67.     local tween = ts:Create(ring, ringTI, {Size = Vector3.new(1000, 0.5, 1000)})
  68.     tween:Play()
  69.  
  70.     ring.Parent = attacksContainer
  71.  
  72.  
  73.     local touched = {}
  74.     ring.Touched:Connect(function(hit)
  75.  
  76.         if hit.Parent:FindFirstChild("Humanoid") and not touched[hit.Parent.Humanoid] and hit.Parent.Humanoid ~= humanoid then
  77.  
  78.             touched[hit.Parent.Humanoid] = true
  79.  
  80.             hit.Parent.Humanoid:TakeDamage(20)
  81.         end
  82.     end)
  83.  
  84.     tween.Completed:Wait()
  85.     ring:Destroy()
  86.    
  87.    
  88.     local hrps = {}
  89.    
  90.     repeat wait()
  91.  
  92.         for i, plr in pairs(game.Players:GetPlayers()) do
  93.  
  94.             if plr.Character and plr.Character:FindFirstChild("HumanoidRootPart") then
  95.  
  96.                 table.insert(hrps, plr.Character.HumanoidRootPart)
  97.             end
  98.         end
  99.     until #hrps > 0
  100.  
  101.     local randomPos = hrps[math.random(1, #hrps)].Position
  102.  
  103.     humanoid:MoveTo(randomPos)
  104.  
  105.     boss.HumanoidRootPart.Velocity = randomPos + Vector3.new(0, game.Workspace.Gravity * 0.7, 0)
  106.  
  107.  
  108.     touched = {}
  109.     local connection = humanoid.Touched:Connect(function(hit)
  110.  
  111.         if hit.Parent:FindFirstChild("Humanoid") and not touched[hit.Parent.Humanoid] then
  112.  
  113.             touched[hit.Parent.Humanoid] = true
  114.  
  115.             hit.Parent.Humanoid:TakeDamage(10)
  116.         end
  117.     end)
  118.  
  119.     wait(5)
  120.     connection:Disconnect()
  121.  
  122.  
  123.     for i = 1, math.random(7, 15) do
  124.  
  125.         local circle = attacks.CircleAttack:Clone()
  126.  
  127.         local randomX = math.random(boss.HumanoidRootPart.Position.X - 100, boss.HumanoidRootPart.Position.X + 100)
  128.         local randomZ = math.random(boss.HumanoidRootPart.Position.Z - 100, boss.HumanoidRootPart.Position.Z + 100)
  129.  
  130.         local y = boss.HumanoidRootPart.Position.Y - humanoid.HipHeight*1.5
  131.  
  132.         local randomPos = Vector3.new(randomX, y, randomZ)
  133.         circle.Position = randomPos
  134.  
  135.  
  136.         local colourTween = ts:Create(circle, fadeTI, {Color = Color3.fromRGB(196, 40, 28)})
  137.         colourTween:Play()
  138.  
  139.         circle.Parent = attacksContainer
  140.  
  141.  
  142.         coroutine.resume(coroutine.create(function()
  143.  
  144.             colourTween.Completed:Wait()
  145.  
  146.  
  147.             local meteor = attacks.Meteor:Clone()
  148.             meteor.Position = circle.Position + Vector3.new(0, 70, 0)
  149.  
  150.             local fallTween = ts:Create(meteor, meteorTI, {Position = circle.Position})
  151.             fallTween:Play()
  152.  
  153.             meteor.Parent = attacksContainer
  154.  
  155.  
  156.             touched = {}
  157.             meteor.Touched:Connect(function(hit)
  158.  
  159.                 if hit.Parent:FindFirstChild("Humanoid") and not touched[hit.Parent.Humanoid] and hit.Parent.Humanoid ~= humanoid then
  160.  
  161.                     touched[hit.Parent.Humanoid] = true
  162.  
  163.                     hit.Parent.Humanoid:TakeDamage(30)
  164.                 end
  165.             end)
  166.  
  167.             fallTween.Completed:Connect(function()
  168.                 meteor:Destroy()
  169.                 circle:Destroy()
  170.             end)
  171.         end))
  172.  
  173.  
  174.         wait(1)
  175.     end
  176. end
RAW Paste Data