KarmaRange

Untitled

Jul 15th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 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. local clone = humanoid.Parent:Clone()
  80. clone.Parent = workspace
  81. clone.Torso.CFrame = humanoid.Parent.Torso.CFrame
  82. humanoid.Parent:Destroy()
  83. local sc = script:Clone()
  84. sc.Parent = clone
  85. local identity = Instance.new("Folder")
  86. identity.Parent = clone
  87. identity.Name = "AIEntity"
  88. clone.Name = "Zombie"
  89. end
  90. wait(0.3)
  91. running_animation_attack:Stop()
  92. running_animation_attack = nil
  93. attack = false
  94. end
  95. end
  96. end
  97.  
  98.  
  99. function findNearestTorso(pos)
  100. local list = game.Workspace:children()
  101. local torso = nil
  102. local dist = 1000
  103. local temp = nil
  104. local human = nil
  105. local temp2 = nil
  106. for x = 1, #list do
  107. temp2 = list[x]
  108. if (temp2.className == "Model") and (temp2 ~= script.Parent) and temp2:FindFirstChild("Zombie") == nil then
  109. temp = temp2:findFirstChild("Torso")
  110. human = temp2:findFirstChild("Humanoid")
  111. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  112. if (temp.Position - pos).magnitude < dist then
  113. torso = temp
  114. dist = (temp.Position - pos).magnitude
  115. end
  116. end
  117. end
  118. end
  119. return torso
  120. end
  121.  
  122. RightArm.Touched:connect(onTouch)
  123. LeftArm.Touched:connect(onTouch)
  124. Torso.Touched:connect(onTouch)
  125. RightLeg.Touched:connect(onTouch)
  126. LeftLeg.Touched:connect(onTouch)
  127.  
  128.  
  129. while true and script.Parent:FindFirstChild("AIEntity") do
  130. wait(math.random(1,5))
  131. local target = findNearestTorso(script.Parent.Torso.Position)
  132. if target ~= nil then
  133. script.Parent.Humanoid:MoveTo(target.Position, target)
  134. end
  135.  
  136. end
Advertisement
Add Comment
Please, Sign In to add comment