Advertisement
KarmaRange

Untitled

Jul 15th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1.  
  2. local e = script.Parent:FindFirstChild("Body Colors")
  3. if e then
  4. e:Destroy()
  5. end
  6.  
  7. script.Name = "Zombie"
  8.  
  9. local animation_attack = Instance.new("Animation")
  10. animation_attack.AnimationId = "http://www.roblox.com/asset/?id=362957401"
  11. local running_animation_attack = nil
  12.  
  13. Character = script.Parent
  14. Humanoid = Character.Humanoid
  15. Torso = Character["Torso"]
  16. Head = Character["Head"]
  17. RightArm = Character["Right Arm"]
  18. LeftArm = Character["Left Arm"]
  19. RightLeg = Character["Right Leg"]
  20. LeftLeg = Character["Left Leg"]
  21. Head.BrickColor = BrickColor.new("Slime green")
  22. RightArm.BrickColor = BrickColor.new("Slime green")
  23. LeftArm.BrickColor = BrickColor.new("Slime green")
  24. LeftLeg.BrickColor = BrickColor.new("Slime green")
  25. RightLeg.BrickColor = BrickColor.new("Slime green")
  26. Torso.BrickColor = BrickColor.new("Slime green")
  27. Humanoid.DisplayDistanceType = "None"
  28. wait(1)
  29. Head.BrickColor = BrickColor.new("Slime green")
  30. RightArm.BrickColor = BrickColor.new("Slime green")
  31. LeftArm.BrickColor = BrickColor.new("Slime green")
  32. LeftLeg.BrickColor = BrickColor.new("Slime green")
  33. RightLeg.BrickColor = BrickColor.new("Slime green")
  34. Torso.BrickColor = BrickColor.new("Slime green")
  35. Humanoid.MaxHealth = "inf"
  36. Humanoid.Health = "inf"
  37. Humanoid.WalkSpeed = 17
  38.  
  39. local BITE = {"131138828","131138835","131138832"}
  40.  
  41. function CreateSound(ID, PARENT, VOLUME, PITCH)
  42. coroutine.resume(coroutine.create(function()
  43. local NEWSOUND = Instance.new("Sound", PARENT)
  44. NEWSOUND.Volume = VOLUME
  45. NEWSOUND.Pitch = PITCH
  46. NEWSOUND.SoundId = "http://www.roblox.com/asset/?id="..ID
  47. NEWSOUND:play()
  48. game:GetService("Debris"):AddItem(NEWSOUND, 10)
  49. end))
  50. end
  51.  
  52. MRANDOM = math.random
  53. attack = false
  54.  
  55.  
  56. function onTouch(part)
  57. Head.BrickColor = BrickColor.new("Slime green")
  58. RightArm.BrickColor = BrickColor.new("Slime green")
  59. LeftArm.BrickColor = BrickColor.new("Slime green")
  60. LeftLeg.BrickColor = BrickColor.new("Slime green")
  61. RightLeg.BrickColor = BrickColor.new("Slime green")
  62. Torso.BrickColor = BrickColor.new("Slime green")
  63. local humanoid = part.Parent:FindFirstChild("Humanoid")
  64. if (humanoid ~= nil) and attack == false and part.Parent:FindFirstChild("Zombie") == nil and part.Parent:FindFirstChild("AIEntity") == nil then
  65. attack = true
  66. game:GetService("ContentProvider"):Preload(animation_attack.AnimationId)
  67. if(running_animation_attack == nil) then
  68. local event_keyframe_reached
  69. running_animation_attack = Humanoid:LoadAnimation(animation_attack)
  70. running_animation_attack:Play()
  71. if humanoid.Health > 1000 then
  72. humanoid.MaxHealth = 100
  73. humanoid.Health = 100
  74. end
  75. CreateSound(BITE[MRANDOM(1, #BITE)], Head, 4, MRANDOM(8, 12) / 10)
  76. CreateSound("201858024", part, 2, math.random(8, 12) / 10)
  77. humanoid.Health = humanoid.Health - 50
  78. if humanoid.Health < 30 then
  79. humanoid.MaxHealth = "inf"
  80. humanoid.Health = "inf"
  81. local clone = humanoid.Parent:Clone()
  82. clone.Parent = workspace
  83. clone.Torso.CFrame = humanoid.Parent.Torso.CFrame
  84. humanoid.Parent:Destroy()
  85. local sc = script:Clone()
  86. sc.Parent = clone
  87. local identity = Instance.new("Folder")
  88. identity.Parent = clone
  89. identity.Name = "AIEntity"
  90. clone.Name = "Zombie"
  91. end
  92. wait(0.3)
  93. running_animation_attack:Stop()
  94. running_animation_attack = nil
  95. attack = false
  96. end
  97. end
  98. end
  99.  
  100.  
  101. function findNearestTorso(pos)
  102. local list = game.Workspace:children()
  103. local torso = nil
  104. local dist = 1000
  105. local temp = nil
  106. local human = nil
  107. local temp2 = nil
  108. for x = 1, #list do
  109. temp2 = list[x]
  110. if (temp2.className == "Model") and (temp2 ~= script.Parent) and temp2:FindFirstChild("Zombie") == nil then
  111. temp = temp2:findFirstChild("Torso")
  112. human = temp2:findFirstChild("Humanoid")
  113. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  114. if (temp.Position - pos).magnitude < dist then
  115. torso = temp
  116. dist = (temp.Position - pos).magnitude
  117. end
  118. end
  119. end
  120. end
  121. return torso
  122. end
  123.  
  124. RightArm.Touched:connect(onTouch)
  125. LeftArm.Touched:connect(onTouch)
  126. Torso.Touched:connect(onTouch)
  127. RightLeg.Touched:connect(onTouch)
  128. LeftLeg.Touched:connect(onTouch)
  129.  
  130.  
  131. while true and script.Parent:FindFirstChild("AIEntity") do
  132. wait(math.random(1,5))
  133. local target = findNearestTorso(script.Parent.Torso.Position)
  134. if target ~= nil then
  135. script.Parent.Humanoid:MoveTo(target.Position, target)
  136. end
  137.  
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement