Advertisement
Blueisim

ZScript (battle)

Jun 10th, 2019
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. --print("zscript by leaquing loaded")
  2. --search
  3. local config=require(script.Config)
  4. local players=workspace.Players
  5. local playerpos={}
  6. local thistorso=script.Parent.Torso
  7. local level=workspace.GameStats.Level
  8. local thishum=script.Parent.Humanoid
  9. local remotes=workspace.Remotes
  10. local parts={}
  11. local deb
  12. for i,v in pairs(script.Parent.ZombieNoises:children()) do
  13. v.Volume=0
  14. end
  15.  
  16. --fix humanoid
  17. --[[script.Parent.Humanoid.MaxHealth=config.health
  18. script.Parent.Humanoid.Health=script.Parent.Humanoid.MaxHealth]]
  19. function search()
  20. for i,v in pairs(playerpos) do
  21. table.remove(playerpos,1)
  22. end
  23. for i,v in pairs(players:children()) do
  24. if v and v.Torso then
  25. table.insert(playerpos,1,v.Torso.Position)
  26. end
  27. end
  28. local lowest=config.sight
  29. local lowestv3
  30. for i,v in pairs(playerpos) do
  31. local dist=math.abs((thistorso.Position-v).magnitude)
  32. if dist<lowest then
  33. lowest=dist
  34. lowestv3=v
  35. end
  36. end
  37.  
  38. if lowest<=((config.sight+(level.Value-1))) then
  39. if lowestv3~=nil then
  40. --print("player spotted at "..tostring(lowestv3))
  41. else
  42. --print("no player spotted!")
  43. end
  44. end
  45. return(lowestv3)
  46. end
  47. function moveto(point)
  48. if point~=nil then
  49. thishum.WalkToPoint=point
  50. end
  51. end
  52. function stopdeb()
  53. deb=false
  54. wait(config.dcooldown)
  55. deb=true
  56. end
  57. --setup parts
  58. for i,v in pairs(script.Parent:children()) do
  59. if v:IsA("Part") then
  60. table.insert(parts,1,v)
  61. end
  62. end
  63. deb=true
  64.  
  65. for i,v in pairs(parts) do
  66. v.BrickColor=BrickColor.new("Bright green")
  67. end
  68. for i,v in pairs(parts) do
  69. if v.Name~="Left Arm" or v.Name~="Right Arm" then
  70. table.remove(parts,i)
  71. end
  72. end
  73. for i,v in pairs(parts) do
  74. v.Touched:connect(function(hitty)
  75. --print(hitty.Name.." of "..hitty.Parent.Name.." boinked")
  76. if deb==true then
  77. --print("can damage")
  78. if thishum.Health>0 then
  79. --print("is alive")
  80. if hitty.Parent:IsDescendantOf(players) then
  81. --print("valid player")
  82. if hitty.Parent:FindFirstChild("Humanoid") then
  83. --print("passed humanoid check")
  84. hitty.Parent.Humanoid:TakeDamage((config.damage+((math.floor((level.Value)/5)+1))*5)-5)
  85. stopdeb()
  86. end
  87. end
  88. end
  89. end
  90. end)
  91. end
  92. --setup face
  93. math.randomseed(tick())
  94. if script.Parent.Head:FindFirstChild("Decal") then
  95. script.Parent.Head:FindFirstChild("Decal"):Destroy()
  96. end
  97. local faced=Instance.new("Decal",script.Parent.Head)
  98. local face=math.random(1,2)
  99. if face==1 then
  100. faced.Texture=config.face1
  101. else
  102. faced.Texture=config.face2
  103. end
  104. coroutine.wrap(function()
  105. while wait(30+math.random(-5.00,5.00)) and thishum.Health>0 do
  106. script.Parent.ZombieNoises:children()[math.random(1,4)]:Play()
  107. math.randomseed(tick()+math.random(1,tick()))
  108. end
  109. end)()
  110. while wait() and thishum.Health>0 do
  111. local clo=search()
  112. moveto(clo)
  113. wait(config.updatespeed-((level.Value)/15))
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement