Advertisement
IHATEMICROWAVEOVEN

Behavior Module

Aug 3rd, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local BHealth = 1000
  3. local sight = 150
  4.  
  5. local function Load(plrcount)
  6. local MaxHealth = BHealth
  7. local Health = MaxHealth
  8. local Name = script.Parent.Name
  9. local Model = script.Parent
  10. spawn(function() require(script.Parent.Animate)() end)
  11. local Humanoid = Model:FindFirstChild("Humanoid")
  12. local infobar = Model.Head.PlayerInfoBar
  13. infobar.PlrName.Text = Model.Name
  14. Humanoid.Health = Health
  15. Humanoid.MaxHealth = MaxHealth
  16. require(script.Parent.Targets).Range(sight)
  17. infobar.HPText.Text = tostring(Health).." / "..tostring(MaxHealth).." HP"
  18.  
  19. local touchhandler = require(game:GetService("ServerScriptService").Libraries.OnTouched)
  20. touchhandler.ConnectEvents(Model:WaitForChild("Torso"))
  21.  
  22. Humanoid.Changed:connect(function()
  23. Health = Humanoid.Health
  24. if infobar == nil then return end
  25. if not infobar:FindFirstChild("HPText") then return end
  26. infobar.HPText.Text = tostring(Health).." / "..tostring(MaxHealth).." HP"
  27. end)
  28. Humanoid.Died:connect(function()
  29. Health = 0
  30. if infobar == nil then return end
  31. if not infobar:FindFirstChild("HPText") then return end
  32. infobar.HPText.Text = tostring(Health).." / "..tostring(MaxHealth).." HP"
  33. end)
  34. Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
  35. Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
  36.  
  37. local startposition = Model.Torso.Position
  38. local Special = true
  39. local CLOSEDAMAGE = 0
  40. local WAITTIME = 2
  41. local range = 10
  42. local DamageMod = require(game:GetService("ServerScriptService").Libraries.DamageService)
  43. spawn(function()
  44. while wait(WAITTIME / 2) and Model:FindFirstChild("SLP") do
  45. if Model.SLP.Value == 0 then
  46. local x = math.random(-range, range)
  47. local z = math.random(-range, range)
  48. Model.Humanoid.WalkToPoint = Vector3.new(startposition.x + x, 0, startposition.z + z)
  49. end
  50. wait(WAITTIME / 2)
  51. if not Model:FindFirstChild("SLP") then return end
  52. if Model.SLP.Value == 0 then
  53. -- FIGHTING
  54. wait(2)
  55. for _, i in pairs(script.Parent.Targets:GetChildren()) do
  56. local player = Players:GetPlayerFromCharacter(workspace:FindFirstChild(i.Name)) or workspace:FindFirstChild(i.Name)
  57. local char = workspace:FindFirstChild(i.Name)
  58. if DamageMod:CanDamage(Model, player) then
  59. local rskill = math.random(1, #script.Skills:GetChildren())
  60. require(script.Skills:GetChildren()[rskill])(Model, char.Torso.Position - (Model.Torso.CFrame * CFrame.new(0,0,-7)).Position)
  61. end
  62. end
  63. end
  64. end
  65. end)
  66.  
  67. repeat wait() until Health <= 0
  68. end
  69.  
  70. return Load
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement