Advertisement
Guest User

NecroDancer no twoamptoytps.t

a guest
Jul 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.63 KB | None | 0 0
  1. --Setting
  2.  
  3. local nametag = "KollowMC" --ForDeathCheck
  4. local Owner = workspace:WaitForChild(nametag) --ForSetting
  5.  
  6. local amount = 12 --Amount of NPC
  7. local sideincreasement = 0 --Go to line 110 for setting
  8. local formationIncreasement = -4 --distance between each line
  9.  
  10. local damage = 50
  11. local health = 400
  12. local speed = 30
  13. local meleedistance = 3
  14. local team = BrickColor.new("Grime")
  15. local attackowner = false
  16. local follow = true
  17. local attack = true
  18.  
  19. wait(2)
  20.  
  21. for I = 1,amount do
  22.  
  23. local parts = Instance.new("Part")
  24. parts.Anchored = true
  25. parts.CanCollide = false
  26.  
  27. local model = Instance.new("Model",workspace)
  28. model.Name = "NPC #"..math.random(100,3000)
  29.  
  30. function OnMotorWeld(name,Primary,Secondary)
  31. local newmotor = Instance.new("Motor6D")
  32. newmotor.Name = name
  33. newmotor.Part0 = Primary
  34. newmotor.Part1 = Secondary
  35. newmotor.C1 = Secondary.CFrame:Inverse()
  36. newmotor.C0 = Primary.CFrame:Inverse()
  37. newmotor.Parent = Primary
  38. end
  39.  
  40. --CharacterCreator--
  41.  
  42. local bodycolor = Instance.new("BodyColors",model)
  43. bodycolor.HeadColor = BrickColor.new("Wheat")
  44. bodycolor.TorsoColor = BrickColor.new("Storm blue")
  45. bodycolor.LeftArmColor = BrickColor.new("Wheat")
  46. bodycolor.RightArmColor = BrickColor.new("Wheat")
  47. bodycolor.LeftLegColor = BrickColor.new("Black")
  48. bodycolor.RightLegColor = BrickColor.new("Black")
  49.  
  50. local head = parts:Clone()
  51. head.Parent = model
  52. head.Name = "Head"
  53. head.Size = Vector3.new(2,1,1)
  54. head.Position = head.Position + Vector3.new(0.5,4.5,0)
  55.  
  56. local specialmesh = Instance.new("SpecialMesh",head)
  57. specialmesh.Scale = Vector3.new(1.25,1.25,1.25)
  58. specialmesh.MeshType = Enum.MeshType.Head
  59.  
  60. local torso = parts:Clone()
  61. torso.Parent = model
  62. torso.Name = "Torso"
  63. torso.Size = Vector3.new(2,2,1)
  64. torso.Position = torso.Position + Vector3.new(0.5,3,0)
  65.  
  66. local Larm = parts:Clone()
  67. Larm.Parent = model
  68. Larm.Name = "Left Arm"
  69. Larm.Size = Vector3.new(1,2,1)
  70. Larm.Position = Larm.Position + Vector3.new(-1,3,0)
  71.  
  72. local Rarm = parts:Clone()
  73. Rarm.Parent = model
  74. Rarm.Name = "Right Arm"
  75. Rarm.Size = Vector3.new(1,2,1)
  76. Rarm.Position = Rarm.Position + Vector3.new(2,3,0)
  77.  
  78. local Lleg = parts:Clone()
  79. Lleg.Parent = model
  80. Lleg.Name = "Left Leg"
  81. Lleg.Size = Vector3.new(1,2,1)
  82. Lleg.Position = Lleg.Position + Vector3.new(0,1,0)
  83.  
  84. local Rleg = parts:Clone()
  85. Rleg.Parent = model
  86. Rleg.Name = "Right Leg"
  87. Rleg.Size = Vector3.new(1,2,1)
  88. Rleg.Position = Rleg.Position + Vector3.new(1,1,0)
  89.  
  90. local humanoidrootpart = parts:Clone()
  91. humanoidrootpart.Parent = model
  92. humanoidrootpart.Name = "HumanoidRootPart"
  93. humanoidrootpart.Size = Vector3.new(2,2,1)
  94. humanoidrootpart.Transparency = 1
  95. humanoidrootpart.Position = humanoidrootpart.Position + Vector3.new(0.5,3,0)
  96.  
  97. model.PrimaryPart = humanoidrootpart
  98.  
  99. local humanoid = Instance.new("Humanoid")
  100. humanoid.Parent = model
  101. humanoid.MaxHealth = health
  102. humanoid.Health = health
  103. humanoid.WalkSpeed = speed
  104. humanoid.Name = "Humanoid"
  105.  
  106. local NPCteam = Instance.new("BrickColorValue",model)
  107. NPCteam.Value = team
  108. NPCteam.Name = "Team"
  109.  
  110. --WeldingMotor6D--
  111.  
  112. OnMotorWeld("RootJoint",humanoidrootpart,torso)
  113. OnMotorWeld("Right Hip",torso,Rleg)
  114. OnMotorWeld("Left Hip",torso,Lleg)
  115. OnMotorWeld("Left Shoulder",torso,Larm)
  116. OnMotorWeld("Right Shoulder",torso,Rarm)
  117. OnMotorWeld("Neck",torso,head)
  118.  
  119. --AnchoredRemover--
  120.  
  121. head.Anchored = false
  122. humanoidrootpart.Anchored = false
  123. torso.Anchored = false
  124. Larm.Anchored = false
  125. Rarm.Anchored = false
  126. Lleg.Anchored = false
  127. Rleg.Anchored = false
  128.  
  129. --Function&Command--
  130.  
  131. model:SetPrimaryPartCFrame(Owner.HumanoidRootPart.CFrame * CFrame.new(-10 + sideincreasement,0.5,formationIncreasement))
  132. if I % 5 ~= 0 then
  133. sideincreasement = sideincreasement + 5 --Distance between person
  134. else
  135. sideincreasement = 0
  136. formationIncreasement = formationIncreasement -4
  137. end
  138.  
  139. --AIfunction
  140.  
  141. local damagecooldown = false
  142.  
  143. function OnAttack(hit)
  144. local ontarget = OnTarget()
  145. local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
  146. if hum and damagecooldown == false and ontarget == hum.Parent then
  147. damagecooldown = true
  148. hum:TakeDamage(damage)
  149. wait(1)
  150. damagecooldown = false
  151. end
  152. end
  153.  
  154. Larm.Touched:Connect(OnAttack)
  155. Rarm.Touched:Connect(OnAttack)
  156.  
  157. function OnTarget()
  158. local children = workspace:GetChildren()
  159. local target = nil
  160. local distance = 100
  161. for I = 1,#children do
  162. local currentchildren = children[I]
  163. if currentchildren.ClassName == "Model" and currentchildren ~= model then
  164. local humanoid = currentchildren:FindFirstChildOfClass("Humanoid")
  165. local rootpart = currentchildren:FindFirstChild("HumanoidRootPart") or currentchildren.PrimaryPart or currentchildren:FindFirstChild("Torso")
  166. local plrcheck = game.Players:GetPlayerFromCharacter(currentchildren)
  167. local enemyteam = currentchildren:FindFirstChild("Team")
  168. if rootpart and humanoid and (currentchildren ~= workspace:FindFirstChild(nametag) or (currentchildren == workspace:FindFirstChild(nametag) and attackowner == true)) then
  169. if plrcheck and enemyteam == nil then
  170. enemyteam = Instance.new("BrickColorValue")
  171. enemyteam.Value = plrcheck.TeamColor
  172. end
  173. if rootpart and humanoid and humanoid.Health > 0 and humanoid.Health < 99999999999 and ((enemyteam == nil or NPCteam == nil) or (NPCteam.Value == BrickColor.new("White") or (enemyteam.Value == BrickColor.new("White") or enemyteam.Value ~= NPCteam.Value))) then
  174. local targetdist = (rootpart.Position - humanoidrootpart.Position).magnitude
  175. if targetdist <= distance then
  176. target = currentchildren
  177. distance = targetdist
  178. end
  179. end
  180. end
  181. end
  182. end
  183. return target
  184. end
  185. spawn(function()
  186. while wait(0.2) do
  187. if humanoid.Health > 0 and workspace:FindFirstChild(nametag) and workspace:FindFirstChild(nametag):FindFirstChildOfClass("Humanoid") and workspace:FindFirstChild(nametag):FindFirstChildOfClass("Humanoid").Health > 0 then
  188. local Target = OnTarget()
  189. print(Target)
  190. if (Target and ((Target ~= workspace:FindFirstChild("KollowMC")) or (Target == workspace:FindFirstChild("KollowMC") and attackowner == true))) and attack == true then
  191. if (Target.PrimaryPart.Position - humanoidrootpart.Position).magnitude > 4 then
  192. humanoid:MoveTo(Target.HumanoidRootPart.Position)
  193. else
  194. humanoid:MoveTo(humanoidrootpart.Position)
  195. end
  196. else
  197. if follow == true and (humanoidrootpart.Position - workspace:FindFirstChild(nametag).HumanoidRootPart.Position).magnitude > 10 then
  198. humanoid:MoveTo(workspace:FindFirstChild(nametag).HumanoidRootPart.Position)
  199. else
  200. humanoid:MoveTo(humanoidrootpart.Position)
  201. end
  202. end
  203. else
  204. model:Remove()
  205. break
  206. end
  207. end
  208.  
  209. end)
  210. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement