Advertisement
Death_Glow

NPC Troll

Apr 13th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.91 KB | None | 0 0
  1. local h = Instance.new('Message',game.Workspace)
  2. h.Text = 'This server is now being populated!'
  3. wait(3)
  4. h:Remove()
  5. while true do
  6. wait(0.5)
  7. maxhealth=999
  8. walkspeed=20
  9. mindamage=100
  10. maxdamage=100
  11. distance=20
  12. CharName=""
  13. armcolor="Black"
  14. legcolor="Black"
  15. torsocolor=Color3.new(math.random(),math.random(),math.random())
  16. headcolor="Cool yellow"
  17. function Part(P, Anch, Coll, Tran, Ref, Col, X, Y, Z)
  18. local p = Instance.new("Part")
  19. p.TopSurface = 0
  20. p.BottomSurface = 0
  21. p.Transparency = Tran
  22. p.Reflectance = Ref
  23. p.CanCollide = Coll
  24. p.Anchored = Anch
  25. p.BrickColor = BrickColor.new(Col)
  26. p.formFactor = "Custom"
  27. p.Size = Vector3.new(X,Y,Z)
  28. p.Parent = P
  29. p.Locked = true
  30. p:BreakJoints()
  31. return p
  32. end
  33.  
  34. function Weld(P0, P1, X, Y, Z, A, B, C)
  35. local w = Instance.new("Weld")
  36. w.Part0 = P0
  37. w.Part1 = P1
  38. w.C1 = CN(X, Y, Z) * CA(A, B, C)
  39. w.Parent = P0
  40. return w
  41. end
  42.  
  43. CA = CFrame.Angles
  44. CN = CFrame.new
  45. V3 = Vector3.new
  46. MR = math.rad
  47. MP = math.pi
  48. MRA = math.random
  49. MH = math.huge
  50.  
  51. Asset = "http://www.roblox.com/asset/?id="
  52. Noob = nil
  53.  
  54. function MakeMotor(torso, p1, c0, c1)
  55. local mot = Instance.new("Motor6D")
  56. mot.C0 = c0
  57. mot.C1 = c1
  58. mot.Part0 = torso
  59. mot.Part1 = p1
  60. mot.Parent = torso
  61. return mot
  62. end
  63.  
  64. function Set(tab)
  65. for _,v in pairs(tab) do
  66. local motor = v[1]
  67. local vel = v[2]
  68. local des = v[3]
  69. motor.MaxVelocity = vel
  70. motor.DesiredAngle = des
  71. end
  72. end
  73.  
  74. function Animate(Hum, RSH, LSH, RH, LH)
  75. local pose = "Standing"
  76. local function sit()
  77. pose = "Seated"
  78. end
  79. local function jump()
  80. pose = "Jumping"
  81. end
  82. local function died()
  83. pose = "Dead"
  84. end
  85. local function falling()
  86. pose = "Falling"
  87. end
  88. local function climbing()
  89. pose = "Climbing"
  90. end
  91. local function run(speed)
  92. if speed > 0.5 then
  93. pose = "Running"
  94. else
  95. pose = "Standing"
  96. end
  97. end
  98. local function move(tiem)
  99. local amplitude, frequency
  100. if pose == "Seated" then
  101. Set({{RSH, 0.15, math.pi/2}, {LSH, 0.15, -math.pi/2}, {LH, 0.15, math.pi/2}, {RH, 0.15, -math.pi/2}})
  102. return
  103. end
  104. if pose == "Jumping" then
  105. Set({{RSH, 0.3, math.pi}, {LSH, 0.3, -math.pi}, {LH, 0.3, 0}, {RH, 0.3, 0}})
  106. return
  107. end
  108. if pose == "Falling" then
  109. Set({{RSH, 0.35, math.pi}, {LSH, 0.35, -math.pi}, {LH, 0.35, 0}, {RH, 0.35, 0}})
  110. return
  111. end
  112. local climb = 0
  113. if pose == "Running" then
  114. RSH.MaxVelocity = 0.15
  115. LSH.MaxVelocity = 0.15
  116. amplitude = 1
  117. frequency = 8
  118. elseif pose == "Climbing" then
  119. RSH.MaxVelocity = 0.3
  120. LSH.MaxVelocity = 0.3
  121. amplitude = 1
  122. frequency = 8
  123. climb = math.pi
  124. else
  125. amplitude = 0.1
  126. frequency = 1
  127. end
  128. des = amplitude * math.sin(tiem*frequency)
  129. RSH.DesiredAngle = des + climb
  130. LSH.DesiredAngle = des - climb
  131. RH.DesiredAngle = -des
  132. LH.DesiredAngle = -des
  133. end
  134. Hum.Jumping:connect(jump)
  135. Hum.Running:connect(run)
  136. Hum.Seated:connect(sit)
  137. Hum.Died:connect(died)
  138. Hum.FreeFalling:connect(falling)
  139. Hum.Climbing:connect(climbing)
  140. coroutine.resume(coroutine.create(function()
  141. while pose ~= "Dead" do
  142. local _, time = wait(0.1)
  143. move(time)
  144. end
  145. end))
  146. end
  147.  
  148. function MakeNoob(pos, scale)
  149. torsocolor=Color3.new(math.random(),math.random(),math.random())
  150. local Nub = Instance.new("Model")
  151. Nub.Name = CharName
  152. Noob = Nub
  153. local Torso = Part(Nub, false, false, 0, 0, torsocolor, 2*scale, 2*scale, 1*scale)
  154. Torso.Name = "Torso"
  155. local Head = Part(Nub, false, false, 0, 0, headcolor, 2*scale, 1*scale, 1*scale)
  156. Head.Name = "Head"
  157. local Neck = MakeMotor(Torso, Head, CN(0, 1*scale, 0), CN(0, -0.5*scale, 0))
  158. local HeadMesh = Instance.new("SpecialMesh",Head)
  159. HeadMesh.Scale = V3(1.25, 1.25, 1.25)
  160. local Face = Instance.new("Decal")
  161. Face.Name="face"
  162. Face.Parent = Head
  163. Face.Face="Front"
  164. asset="http://www.roblox.com/asset/?id="
  165. id1="8348827"
  166. id2="34818288"
  167. id3="33950936"
  168. id4="76309089"
  169. dur=math.random(1,4)
  170. if dur==1 then
  171. Face.Texture = asset .. id1
  172. elseif dur==2 then
  173. Face.Texture = asset .. id2
  174. elseif dur==3 then
  175. Face.Texture = asset .. id3
  176. elseif dur==4 then
  177. Face.Texture = asset .. id4
  178. end
  179. local Rarm = Part(Nub, false, false, 0, 0, armcolor, 1*scale, 2*scale, 1*scale)
  180. Rarm.Name = "Right Arm"
  181. local Larm = Part(Nub, false, false, 0, 0, armcolor, 1*scale, 2*scale, 1*scale)
  182. Larm.Name = "Left Arm"
  183. local Rleg = Part(Nub, false, false, 0, 0, legcolor, 1*scale, 2*scale, 1*scale)
  184. Rleg.Name = "Right Leg"
  185. local Lleg = Part(Nub, false, false, 0, 0, legcolor, 1*scale, 2*scale, 1*scale)
  186. Lleg.Name = "Left Leg"
  187.  
  188. attackdebounce=false
  189. CRIT=false
  190. Damagefunc1=function(hit,lowdamage,highdamage,Knockback)
  191. if attackdebounce == false then
  192. attackdebounce = true
  193. coroutine.resume(coroutine.create(function()
  194. wait(0.1)
  195. attackdebounce = false
  196. end))
  197. if hit.Parent==nil then
  198. return
  199. end
  200. h=hit.Parent:FindFirstChild("Humanoid")
  201. if h~=nil and hit.Parent:FindFirstChild("Torso")~=nil then
  202. Damage=Damage
  203. --[[ if game.Players:GetPlayerFromCharacter(hit.Parent)~=nil then
  204. return
  205. end]]
  206. -- print(c.Value)
  207. Damage=math.random(lowdamage,highdamage)
  208. h:TakeDamage(Damage)
  209. showDamage(hit.Parent,Damage,.5)
  210. vp=Instance.new("BodyVelocity")
  211. vp.P=500
  212. vp.maxForce=Vector3.new(math.huge,0,math.huge)
  213. -- vp.velocity=Character.Torso.CFrame.lookVector*Knockback
  214. vp.velocity=Torso.CFrame.lookVector*Knockback+Torso.Velocity/1.05
  215. if Knockback>0 then
  216. vp.Parent=hit.Parent.Torso
  217. end
  218. game:GetService("Debris"):AddItem(vp,.25)
  219. CRIT=false
  220. hitDeb=true
  221. AttackPos=6
  222. end
  223. end
  224. end
  225.  
  226. showDamage=function(Char,Dealt,du)
  227. m=Instance.new("Model")
  228. m.Name=tostring(Dealt)
  229. h=Instance.new("Humanoid")
  230. h.Health=0
  231. h.MaxHealth=0
  232. h.Parent=m
  233. c=Instance.new("Part")
  234. c.Transparency=0
  235. c.BrickColor=BrickColor:Red()
  236. if CRIT==true then
  237. c.BrickColor=BrickColor.new("Really red")
  238. end
  239. c.Name="Head"
  240. c.TopSurface=0
  241. c.BottomSurface=0
  242. c.formFactor="Plate"
  243. c.Size=Vector3.new(1,.4,1)
  244. ms=Instance.new("CylinderMesh")
  245. ms.Scale=Vector3.new(.8,.8,.8)
  246. if CRIT==true then
  247. ms.Scale=Vector3.new(1.25,1.5,1.25)
  248. end
  249. ms.Parent=c
  250. c.Reflectance=0
  251. Instance.new("BodyGyro").Parent=c
  252. c.Parent=m
  253. c.CFrame=CFrame.new(Char["Head"].CFrame.p+Vector3.new(0,1.5,0))
  254. f=Instance.new("BodyPosition")
  255. f.P=2000
  256. f.D=100
  257. f.maxForce=Vector3.new(math.huge,math.huge,math.huge)
  258. f.position=c.Position+Vector3.new(0,3,0)
  259. f.Parent=c
  260. game:GetService("Debris"):AddItem(m,.5+du)
  261. c.CanCollide=false
  262. m.Parent=workspace
  263. c.CanCollide=false
  264. end
  265.  
  266. local larm = Larm
  267. local rarm = Rarm
  268.  
  269. function findNearestTorso(pos)
  270. local list = game.Workspace:children()
  271. local torso = nil
  272. local dist = distance
  273. local temp = nil
  274. local human = nil
  275. local temp2 = nil
  276. for x = 1, #list do
  277. temp2 = list[x]
  278. if (temp2.className == "Model") and (temp2 ~= Nub) and (temp2.Name~=CharName) then
  279. temp = temp2:findFirstChild("Torso")
  280. human = temp2:findFirstChild("Humanoid")
  281. if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
  282. if (temp.Position - pos).magnitude < dist then
  283. torso = temp
  284. dist = (temp.Position - pos).magnitude
  285. end
  286. end
  287. end
  288. end
  289. return torso
  290. end
  291.  
  292. so = function(id,par,vol,pit)
  293. coroutine.resume(coroutine.create(function()
  294. local sou = Instance.new("Sound",par or workspace)
  295. sou.Volume=vol
  296. sou.Pitch=pit or 1
  297. sou.SoundId=id
  298. wait()
  299. sou:play()
  300. wait(6)
  301. sou:Remove()
  302. end))
  303. end
  304.  
  305. local RSH = MakeMotor(Torso, Rarm, CN(1*scale, 0.5*scale, 0) * CA(0, MR(90), 0), CN(-0.5*scale, 0.5*scale, 0) * CA(0, MR(90), 0))
  306. RSH.Name="Right Shoulder"
  307. local LSH = MakeMotor(Torso, Larm, CN(-1*scale, 0.5*scale, 0) * CA(0, MR(-90), 0), CN(0.5*scale, 0.5*scale, 0) * CA(0, MR(-90), 0))
  308. LSH.Name="Left Shoulder"
  309. local RH = MakeMotor(Torso, Rleg, CN(0.5*scale, -1*scale, 0) * CA(0, MR(-90), 0), CN(0, 1*scale, 0) * CA(0, MR(-90), 0))
  310. RH.Name="Right Hip"
  311. local LH = MakeMotor(Torso, Lleg, CN(-0.5*scale, -1*scale, 0) * CA(0, MR(90), 0), CN(0, 1*scale, 0) * CA(0, MR(90), 0))
  312. LH.Name="Left Hip"
  313. local Hum = Instance.new("Humanoid")
  314. Hum.MaxHealth = maxhealth
  315. Hum.Health = Hum.MaxHealth
  316. Hum.WalkSpeed = walkspeed
  317. coroutine.resume(coroutine.create(function()
  318. for i=1,30 do
  319. wait(0)
  320. Hum.MaxHealth = maxhealth
  321. Hum.Health = maxhealth
  322. end
  323. Hum:TakeDamage(1)
  324. Hum.Health=Hum.MaxHealth
  325. end))
  326. wander=false
  327. coroutine.resume(coroutine.create(function(Humanoid)
  328. wait(1)
  329. Humanoid.Health=Humanoid.MaxHealth
  330. Humanoid:TakeDamage(1)
  331. end),Hum)
  332. Hum.Parent = Nub
  333. Nub.Parent = workspace
  334. Nub:MakeJoints()
  335. Nub:MoveTo(pos)
  336. Animate(Hum,RSH,LSH,RH,LH)
  337. coroutine.resume(coroutine.create(function(Character)
  338. local con1=nil
  339. local con2=nil
  340. while Character.Parent~=nil do
  341. wait()
  342. target = findNearestTorso(Character.Torso.Position)
  343. wander=false
  344. if target~=nil then
  345. Character.Humanoid:MoveTo(target.Position, target)
  346. local targ = target.Position - Torso.Position
  347. local magni = targ.magnitude
  348. if magni<=10 then
  349. Tors=Character.Torso
  350. RightArm=Character["Right Arm"]
  351. LeftArm=Character["Left Arm"]
  352. RightLeg=Character["Right Leg"]
  353. LeftLeg=Character["Left Leg"]
  354. if math.random(1,2)==1 then
  355. local RSH = Torso["Right Shoulder"]
  356. RSH.Parent = nil
  357. local RW = Instance.new("Weld")
  358. RW.Parent = RightArm
  359. RW.Part0 = Torso
  360. RW.Part1 = RightArm
  361. RW.C0 = CFrame.new((1.5)*scale, (0.5)*scale, 0)
  362. RW.C1 = CFrame.new(0, (0.5)*scale, 0)
  363. con1=RightArm.Touched:connect(function(hit) Damagefunc1(hit,mindamage,maxdamage,3) end)
  364. con2=RightLeg.Touched:connect(function(hit) Damagefunc1(hit,mindamage,maxdamage,3) end)
  365. so("http://roblox.com/asset/?id=10209640",Tors,0.5,math.random())
  366. for i = 0,1,0.2 do
  367. wait()
  368. RW.C0 = CFrame.new((1.5-0.5*i)*scale,(0.5)*scale,(-0.5*i)*scale)*CFrame.fromEulerAnglesXYZ(2*i,0,-0.5*i)
  369. end
  370. for i = 0,1,0.2 do
  371. wait()
  372. RW.C0 = CFrame.new((1.5-0.5+0.5*i)*scale,(0.5)*scale,(-0.5+0.5*i)*scale)*CFrame.fromEulerAnglesXYZ(2-2*i,0,-0.5+0.5*i)
  373. end
  374. con1:disconnect()
  375. con2:disconnect()
  376. wait(1)
  377. RW.Parent=nil
  378. RSH.Parent=Torso
  379. else
  380. local LSH = Torso["Left Shoulder"]
  381. LSH.Parent = nil
  382. local LW = Instance.new("Weld")
  383. LW.Parent = LeftArm
  384. LW.Part0 = Torso
  385. LW.Part1 = LeftArm
  386. LW.C0 = CFrame.new((-1.5)*scale, (0.5)*scale, 0)
  387. LW.C1 = CFrame.new(0, (0.5)*scale, 0)
  388. con1=LeftArm.Touched:connect(function(hit) Damagefunc1(hit,mindamage,maxdamage,3) end)
  389. con2=LeftLeg.Touched:connect(function(hit) Damagefunc1(hit,mindamage,maxdamage,3) end)
  390. so("http://roblox.com/asset/?id=10209640",Torso,0.5,math.random())
  391. for i = 0,1,0.2 do
  392. wait()
  393. LW.C0 = CFrame.new((-1.5+0.5*i)*scale,(0.5)*scale,(-0.5*i)*scale)*CFrame.fromEulerAnglesXYZ(2*i,0,0.5*i)
  394. end
  395. for i = 0,1,0.2 do
  396. wait()
  397. LW.C0 = CFrame.new((-1.5+0.5-0.5*i)*scale,(0.5)*scale,(-0.5+0.5*i)*scale)*CFrame.fromEulerAnglesXYZ(2-2*i,0,0.5-0.5*i)
  398. end
  399. con1:disconnect()
  400. con2:disconnect()
  401. LW.Parent = nil
  402. LSH.Parent = Torso
  403. end
  404. end
  405. else
  406. if wander==false then
  407. wander=true
  408. Character.Humanoid:MoveTo(game:GetService("Workspace").Base.Position + Vector3.new(math.random(-game:GetService("Workspace").Base.Size.x, game:GetService("Workspace").Base.Size.x), math.random(-game:GetService("Workspace").Base.Size.y, game:GetService("Workspace").Base.Size.y), math.random(-game:GetService("Workspace").Base.Size.z, game:GetService("Workspace").Base.Size.z)), game:GetService("Workspace").Base)
  409. -- Humanoid:MoveTo(game:GetService("Workspace").Base.Position, game:GetService("Workspace").Base)
  410. for i=0,math.random(100,500) do
  411. if target==nil then
  412. wait()
  413. end
  414. end
  415. wander=false
  416. end
  417. end
  418. end
  419. end),Nub)
  420. Hum.Died:connect(function()
  421. wait(6)
  422. Nub:remove()
  423. wait(4)
  424. torsocolor=Color3.new(math.random(),math.random(),math.random())
  425. MakeNoob(V3(MRA(-300, 300),10,MRA(-300, 300)), scale)
  426. end)
  427. return Nub
  428. end
  429. for i = 1, 10 do
  430. local nub = MakeNoob(V3(MRA(-300, 300),10,MRA(-300, 300)), 1)
  431. end
  432. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement