SHARE
TWEET

NPC zombie summon

sina4 Jan 29th, 2020 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. soldier157 = Instance.new("Model")
  2. soldier157.Parent = game.Workspace
  3. soldier157.Name = "zombie157"
  4.  
  5.  
  6. LA = Instance.new("Part")
  7. LA.Parent = soldier157
  8. LA.Name = "Left Arm"
  9. LA.Size = Vector3.new(1, 2, 1)
  10. LA.Transparency = 1
  11.  
  12. RA = Instance.new("Part")
  13. RA.Parent = soldier157
  14. RA.Name = "Right Arm"
  15. RA.Size = Vector3.new(1, 2, 1)
  16. RA.Transparency = 1
  17.  
  18. Head = Instance.new("Part")
  19. Head.Parent = soldier157
  20. Head.Name = "Head"
  21. Head.Size = Vector3.new(0.1, 0.1, 0.1)
  22. Head.Transparency = 1
  23.  
  24. grrrr = Instance.new("Sound")
  25. grrrr.Parent = Head
  26. grrrr.SoundId = "rbxassetid://300708180"
  27. grrrr.Volume = 7
  28.  
  29. Torso = Instance.new("Part")
  30. Torso.Parent = soldier157
  31. Torso.Name = "Torso"
  32. Torso.Size = Vector3.new(4, 5, 1)
  33. soldier157.PrimaryPart =Torso
  34.  
  35. LL = Instance.new("Part")
  36. LL.Parent = soldier157
  37. LL.Name ="Left Leg"
  38. LL.Size = Vector3.new(1, 2, 1)
  39. LL.Transparency = 1
  40.  
  41.  
  42. RL = Instance.new("Part")
  43. RL.Parent = soldier157
  44. RL.Name = "Right Leg"
  45. RL.Size = Vector3.new(1, 2, 1)
  46. RL.Transparency = 1
  47.  
  48.  
  49. humanoid = Instance.new("Humanoid")
  50. humanoid.Parent = soldier157
  51. humanoid.WalkSpeed = 17
  52. humanoid.HipHeight = -2
  53.  
  54.  
  55. snap = Instance.new("Snap")
  56. snap.Parent = soldier157.Torso
  57. snap.Part0 = Torso
  58. snap.Part1 = Head
  59.  
  60. LH = Instance.new("Motor")
  61. LH.Parent = soldier157.Torso
  62. LH.Part0 = Torso
  63. LH.Part1 = LL
  64.  
  65. LS = Instance.new("Motor")
  66. LS.Parent = soldier157.Torso
  67. LS.Part0 = Torso
  68. LS.Part1 = LA
  69.  
  70. RH = Instance.new("Motor")
  71. RH.Parent = soldier157.Torso
  72. RH.Part0 = Torso
  73. RH.Part1 = RL
  74.  
  75. RS = Instance.new("Motor")
  76. RS.Parent = soldier157.Torso
  77. RS.Part0 = Torso
  78. RS.Part1 = RA
  79.  
  80. skin = Instance.new("SpecialMesh")
  81. skin.MeshId = "rbxassetid://2711200539"
  82. skin.TextureId = "rbxassetid://4533685150"
  83. skin.Parent =soldier157
  84. skin.Parent = Torso
  85.  
  86.  
  87.  
  88. healthbar = Instance.new("BillboardGui")
  89. healthbar.Parent = Head
  90. healthbar.Size = UDim2.new(10, 0,1.2, 0)
  91. healthbar.StudsOffsetWorldSpace = Vector3.new(-1, 3.5, 0)
  92.  
  93.  
  94.  
  95. Namee = Instance.new("Frame")
  96. Namee.Parent = healthbar
  97. Namee.BorderColor3 = Color3.new(27,42,53)
  98. Namee.BackgroundColor3 = Color3.new(255,255,255)
  99. Namee.Size = UDim2.new(1, 0,0.35, 0)
  100. Namee.BackgroundTransparency = 1
  101.  
  102. NpcName = Instance.new("TextLabel")
  103. NpcName.Parent = Namee
  104. NpcName.TextStrokeColor3 = Color3.new(0,0,0)
  105. NpcName.TextColor3 = Color3.new(0,255,0)
  106. NpcName.Text = "      sina157's Zombie"
  107. NpcName.Size = UDim2.new(0.75, 0,2, 0)
  108. NpcName.BackgroundTransparency = 1
  109. NpcName.TextSize = 14
  110. NpcName.TextStrokeTransparency = 0
  111.  
  112.  
  113.  
  114. wait()
  115.  
  116. script.Parent = soldier157
  117.  
  118. local larm = script.Parent:FindFirstChild("Left Arm")
  119. local rarm = script.Parent:FindFirstChild("Right Arm")
  120.  
  121. function findNearestTorso(pos)
  122.     local list = game.Workspace:children()
  123.     local torso = nil
  124.     local dist = 1000 --This Line Right Here
  125.     local temp = nil
  126.     local human = nil
  127.     local temp2 = nil
  128.     for x = 1, #list do
  129.         temp2 = list[x]
  130.         if (temp2.className == "Model") and (temp2 ~= script.Parent) then
  131.             temp = temp2:findFirstChild("Head")
  132.             human = temp2:findFirstChild("Humanoid")
  133.             Ally = game.Workspace:findFirstChild("zombie157")
  134.             if (temp ~= nil) and (human ~= nil) and (human.Health > 0) and (Ally == nil) or (temp ~= nil) and (human ~= nil) and (human.Health > 0) and (human.Parent.Name ~= "zombie157") and (human.Parent.Name ~= "sina157")  then
  135.                
  136.                 if (temp.Position - pos).magnitude < dist then
  137.                     torso = temp
  138.                     dist = (temp.Position - pos).magnitude
  139.                 end
  140.             end
  141.         end
  142.     end
  143.        
  144.     x = math.random(0,17)
  145.     if x == 15 then
  146.         humanoid.Jump = true
  147.     end
  148.     return torso
  149. end
  150.  
  151.  
  152. function dgm(hit)
  153.     humanoid.Health  = humanoid.Health + 0.1
  154.     h = hit.Parent:findFirstChild("Humanoid")
  155.     if not h then
  156.         return
  157.     end
  158. if  not hit.Parent:findFirstChild("Humanoid") then
  159.     humanoid.Health  = humanoid.Health + 10
  160.     humanoid.MaxHealth  = humanoid.MaxHealth + 3
  161. end
  162. if hit.Parent.Name ~= "sina157" and hit.Parent.Name ~= "zombie157" then
  163.     hit.Parent:findFirstChild("Humanoid"):TakeDamage(5)
  164.     end
  165. end
  166.  
  167. Torso.Touched:Connect(dgm)
  168. Head.Touched:Connect(dgm)
  169.  
  170.  
  171. function jump(j)
  172. grrrr:Play()
  173. end
  174.  
  175. humanoid.Jumping:Connect(jump)
  176.  
  177. while true do
  178.     wait(0.1)
  179.     if Torso == nil or humanoid.Health == 0 then
  180.         script.Parent:Destroy()
  181.     end
  182.    
  183.     local target = findNearestTorso(script.Parent.Torso.Position)
  184.     if target ~= nil then
  185.         script.Parent.Humanoid:MoveTo(target.Position, target)
  186.  
  187.     end
  188. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top