Advertisement
Webcat70

aienemy

Jan 2nd, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 47.02 KB | None | 0 0
  1. function sandbox(var,func)
  2.     local env = getfenv(func)
  3.     local newenv = setmetatable({},{
  4.         __index = function(self,k)
  5.             if k=="script" then
  6.                 return var
  7.             else
  8.                 return env[k]
  9.             end
  10.         end,
  11.     })
  12.     setfenv(func,newenv)
  13.     return func
  14. end
  15. cors = {}
  16. mas = Instance.new("Model",game:GetService("Lighting"))
  17. Model0 = Instance.new("Model")
  18. Part1 = Instance.new("Part")
  19. SpecialMesh2 = Instance.new("SpecialMesh")
  20. Decal3 = Instance.new("Decal")
  21. Script4 = Instance.new("Script")
  22. Script5 = Instance.new("Script")
  23. Weld6 = Instance.new("Weld")
  24. Weld7 = Instance.new("Weld")
  25. Part8 = Instance.new("Part")
  26. Motor6D9 = Instance.new("Motor6D")
  27. Motor6D10 = Instance.new("Motor6D")
  28. Weld11 = Instance.new("Weld")
  29. Weld12 = Instance.new("Weld")
  30. Script13 = Instance.new("Script")
  31. Part14 = Instance.new("Part")
  32. Script15 = Instance.new("Script")
  33. Part16 = Instance.new("Part")
  34. Weld17 = Instance.new("Weld")
  35. Script18 = Instance.new("Script")
  36. Part19 = Instance.new("Part")
  37. Script20 = Instance.new("Script")
  38. Part21 = Instance.new("Part")
  39. Script22 = Instance.new("Script")
  40. Humanoid23 = Instance.new("Humanoid")
  41. Hat24 = Instance.new("Hat")
  42. Part25 = Instance.new("Part")
  43. SpecialMesh26 = Instance.new("SpecialMesh")
  44. Script27 = Instance.new("Script")
  45. Part28 = Instance.new("Part")
  46. Sound29 = Instance.new("Sound")
  47. Sound30 = Instance.new("Sound")
  48. Script31 = Instance.new("Script")
  49. Script32 = Instance.new("Script")
  50. Hat33 = Instance.new("Hat")
  51. Part34 = Instance.new("Part")
  52. SpecialMesh35 = Instance.new("SpecialMesh")
  53. Part36 = Instance.new("Part")
  54. SpecialMesh37 = Instance.new("SpecialMesh")
  55. Script38 = Instance.new("Script")
  56. Pants39 = Instance.new("Pants")
  57. Shirt40 = Instance.new("Shirt")
  58. Script41 = Instance.new("Script")
  59. Script42 = Instance.new("Script")
  60. Script43 = Instance.new("Script")
  61. Model0.Name = "Communist"
  62. Model0.Parent = mas
  63. Model0.PrimaryPart = Part1
  64. Part1.Name = "Head"
  65. Part1.Parent = Model0
  66. Part1.CFrame = CFrame.new(20.5216675, 4.50000811, 71.3955078, 1, 0, 3.70398773e-17, 0, 1, 0, 3.70398773e-17, 0, 1)
  67. Part1.Position = Vector3.new(20.5216675, 4.50000811, 71.3955078)
  68. Part1.Color = Color3.new(0.917647, 0.721569, 0.572549)
  69. Part1.Size = Vector3.new(2, 1, 1)
  70. Part1.BrickColor = BrickColor.new("Light orange")
  71. Part1.TopSurface = Enum.SurfaceType.Smooth
  72. Part1.brickColor = BrickColor.new("Light orange")
  73. Part1.FormFactor = Enum.FormFactor.Symmetric
  74. Part1.formFactor = Enum.FormFactor.Symmetric
  75. SpecialMesh2.Parent = Part1
  76. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  77. Decal3.Parent = Part1
  78. Decal3.Texture = "http://www.roblox.com/asset/?id=221967384"
  79. Script4.Parent = Part1
  80. table.insert(cors,sandbox(Script4,function()
  81. function blow(hit)
  82.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  83.  
  84.     if humanoid~=nil then
  85.         humanoid:TakeDamage(25)
  86.     end
  87. end
  88.  
  89.  
  90.  
  91. connection = script.Parent.Touched:connect(blow)
  92.  
  93.  
  94.  
  95. end))
  96. Script5.Name = "PlaySounds"
  97. Script5.Parent = Part1
  98. table.insert(cors,sandbox(Script5,function()
  99. zombieParent = false
  100.  
  101. local soundIds = {113306429,111896685,113306429}
  102. local sounds = {}
  103. for i=1,#soundIds do
  104.     local s = Instance.new("Sound")
  105.     s.SoundId = "http://www.roblox.com/asset/?id=" .. soundIds[i]
  106.     s.Volume = 1
  107.     s.Parent = script.Parent
  108.     sounds[#sounds + 1] = s
  109. end
  110.  
  111. while zombieParent == false do
  112.  
  113.     wait(1)
  114.     if script.Parent.Name == "Head" then
  115.         zombieParent = true
  116.     end
  117.  
  118. end
  119.  
  120. while true do
  121.     wait(math.random(20,35))
  122.     local i = math.random(1, #sounds)
  123.     sounds[i].Pitch = 1
  124.     sounds[i]:Play()
  125. end
  126. end))
  127. Weld6.Name = "HeadWeld"
  128. Weld6.Parent = Part1
  129. Weld6.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  130. Weld6.C1 = CFrame.new(0, 0.349999994, 0, 1, 0, -0, 0, 0.995037258, 0.0995037109, 0, -0.0995037258, 0.995037138)
  131. Weld6.Part0 = Part1
  132. Weld6.Part1 = Part25
  133. Weld6.part1 = Part25
  134. Weld7.Name = "HeadWeld"
  135. Weld7.Parent = Part1
  136. Weld7.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  137. Weld7.C1 = CFrame.new(0, -0.100000001, 0, 1, 0, -0, 0, 0.995037258, 0.0995037109, 0, -0.0995037258, 0.995037138)
  138. Weld7.Part0 = Part1
  139. Weld7.Part1 = Part34
  140. Weld7.part1 = Part34
  141. Part8.Name = "Torso"
  142. Part8.Parent = Model0
  143. Part8.CFrame = CFrame.new(20.5216675, 3.00000811, 71.3955078, 1, 0, 1.23466252e-17, 0, 1, 0, 1.23466252e-17, 0, 1)
  144. Part8.Position = Vector3.new(20.5216675, 3.00000811, 71.3955078)
  145. Part8.Color = Color3.new(0.917647, 0.721569, 0.572549)
  146. Part8.Size = Vector3.new(2, 2, 1)
  147. Part8.BrickColor = BrickColor.new("Light orange")
  148. Part8.LeftParamA = 0
  149. Part8.LeftParamB = 0
  150. Part8.LeftSurface = Enum.SurfaceType.Weld
  151. Part8.RightParamA = 0
  152. Part8.RightParamB = 0
  153. Part8.RightSurface = Enum.SurfaceType.Weld
  154. Part8.brickColor = BrickColor.new("Light orange")
  155. Part8.FormFactor = Enum.FormFactor.Symmetric
  156. Part8.formFactor = Enum.FormFactor.Symmetric
  157. Motor6D9.Name = "Right Hip"
  158. Motor6D9.Parent = Part8
  159. Motor6D9.MaxVelocity = 0.10000000149012
  160. Motor6D9.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  161. Motor6D9.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  162. Motor6D9.Part0 = Part8
  163. Motor6D9.Part1 = Part21
  164. Motor6D9.part1 = Part21
  165. Motor6D10.Name = "Left Hip"
  166. Motor6D10.Parent = Part8
  167. Motor6D10.MaxVelocity = 0.10000000149012
  168. Motor6D10.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  169. Motor6D10.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  170. Motor6D10.Part0 = Part8
  171. Motor6D10.Part1 = Part19
  172. Motor6D10.part1 = Part19
  173. Weld11.Parent = Part8
  174. Weld11.C1 = CFrame.new(0.800000012, 0.5, 0.400000006, 0.766044438, 0, 0.642787576, -0.642787576, 1.19248806e-08, 0.766044438, -7.66516539e-09, -1, 9.13498877e-09)
  175. Weld11.Part0 = Part8
  176. Weld11.Part1 = Part14
  177. Weld11.part1 = Part14
  178. Weld12.Parent = Part8
  179. Weld12.C1 = CFrame.new(-1.20000005, 0.5, 0.400000006, 0.99619472, 0, -0.087155737, 0.087155737, 1.19248806e-08, 0.99619472, 1.03932174e-09, -1, 1.18795027e-08)
  180. Weld12.Part0 = Part8
  181. Weld12.Part1 = Part16
  182. Weld12.part1 = Part16
  183. Script13.Parent = Part8
  184. table.insert(cors,sandbox(Script13,function()
  185. function blow(hit)
  186.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  187.  
  188.     if humanoid~=nil then
  189.         humanoid:TakeDamage(25)
  190.     end
  191. end
  192.  
  193.  
  194.  
  195. connection = script.Parent.Touched:connect(blow)
  196.  
  197.  
  198.  
  199. end))
  200. Part14.Name = "Left Arm"
  201. Part14.Parent = Model0
  202. Part14.CFrame = CFrame.new(20.2302265, 3.4000082, 70.4982529, 0.766044438, -0.642787576, -7.66516539e-09, 0, 1.19248806e-08, -1, 0.642787576, 0.766044438, 9.13498877e-09)
  203. Part14.Orientation = Vector3.new(90, -40, 0)
  204. Part14.Position = Vector3.new(20.2302265, 3.4000082, 70.4982529)
  205. Part14.Rotation = Vector3.new(90, 0, 40)
  206. Part14.Color = Color3.new(0.917647, 0.721569, 0.572549)
  207. Part14.Size = Vector3.new(1, 2, 1)
  208. Part14.BrickColor = BrickColor.new("Light orange")
  209. Part14.CanCollide = false
  210. Part14.brickColor = BrickColor.new("Light orange")
  211. Part14.FormFactor = Enum.FormFactor.Symmetric
  212. Part14.formFactor = Enum.FormFactor.Symmetric
  213. Script15.Parent = Part14
  214. table.insert(cors,sandbox(Script15,function()
  215. function blow(hit)
  216.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  217.  
  218.     if humanoid~=nil then
  219.         humanoid:TakeDamage(25)
  220.     end
  221. end
  222.  
  223.  
  224.  
  225. connection = script.Parent.Touched:connect(blow)
  226.  
  227.  
  228.  
  229. end))
  230. Part16.Name = "Right Arm"
  231. Part16.Parent = Model0
  232. Part16.CFrame = CFrame.new(21.6735229, 3.4000082, 70.7928238, 0.99619472, 0.087155737, 1.03932174e-09, 0, 1.19248806e-08, -1, -0.087155737, 0.99619472, 1.18795027e-08)
  233. Part16.Orientation = Vector3.new(90, 5, 0)
  234. Part16.Position = Vector3.new(21.6735229, 3.4000082, 70.7928238)
  235. Part16.Rotation = Vector3.new(90, 0, -5)
  236. Part16.Color = Color3.new(0.917647, 0.721569, 0.572549)
  237. Part16.Size = Vector3.new(1, 2, 1)
  238. Part16.BrickColor = BrickColor.new("Light orange")
  239. Part16.CanCollide = false
  240. Part16.brickColor = BrickColor.new("Light orange")
  241. Part16.FormFactor = Enum.FormFactor.Symmetric
  242. Part16.formFactor = Enum.FormFactor.Symmetric
  243. Weld17.Name = "RightGrip"
  244. Weld17.Parent = Part16
  245. Weld17.C0 = CFrame.new(0, -1, 0, 1, 0, -0, 0, 0, 1, 0, -1, 0)
  246. Weld17.C1 = CFrame.new(0, -0.200000003, 0.200000003, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  247. Weld17.Part0 = Part16
  248. Weld17.Part1 = Part28
  249. Weld17.part1 = Part28
  250. Script18.Parent = Part16
  251. table.insert(cors,sandbox(Script18,function()
  252. function blow(hit)
  253.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  254.  
  255.     if humanoid~=nil then
  256.         humanoid:TakeDamage(25)
  257.     end
  258. end
  259.  
  260.  
  261.  
  262. connection = script.Parent.Touched:connect(blow)
  263.  
  264.  
  265.  
  266. end))
  267. Part19.Name = "Left Leg"
  268. Part19.Parent = Model0
  269. Part19.CFrame = CFrame.new(20.0216675, 1.00000811, 71.3955078, 1, 0, 1.23466252e-17, 0, 1, 0, 1.23466252e-17, 0, 1)
  270. Part19.Position = Vector3.new(20.0216675, 1.00000811, 71.3955078)
  271. Part19.Color = Color3.new(0.917647, 0.721569, 0.572549)
  272. Part19.Size = Vector3.new(1, 2, 1)
  273. Part19.BottomSurface = Enum.SurfaceType.Smooth
  274. Part19.BrickColor = BrickColor.new("Light orange")
  275. Part19.CanCollide = false
  276. Part19.brickColor = BrickColor.new("Light orange")
  277. Part19.FormFactor = Enum.FormFactor.Symmetric
  278. Part19.formFactor = Enum.FormFactor.Symmetric
  279. Script20.Parent = Part19
  280. table.insert(cors,sandbox(Script20,function()
  281. function blow(hit)
  282.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  283.  
  284.     if humanoid~=nil then
  285.         humanoid:TakeDamage(25)
  286.     end
  287. end
  288.  
  289.  
  290.  
  291. connection = script.Parent.Touched:connect(blow)
  292.  
  293.  
  294.  
  295. end))
  296. Part21.Name = "Right Leg"
  297. Part21.Parent = Model0
  298. Part21.CFrame = CFrame.new(21.0216675, 1.00000811, 71.3955078, 1, 0, 1.23466252e-17, 0, 1, 0, 1.23466252e-17, 0, 1)
  299. Part21.Position = Vector3.new(21.0216675, 1.00000811, 71.3955078)
  300. Part21.Color = Color3.new(0.917647, 0.721569, 0.572549)
  301. Part21.Size = Vector3.new(1, 2, 1)
  302. Part21.BottomSurface = Enum.SurfaceType.Smooth
  303. Part21.BrickColor = BrickColor.new("Light orange")
  304. Part21.CanCollide = false
  305. Part21.brickColor = BrickColor.new("Light orange")
  306. Part21.FormFactor = Enum.FormFactor.Symmetric
  307. Part21.formFactor = Enum.FormFactor.Symmetric
  308. Script22.Parent = Part21
  309. table.insert(cors,sandbox(Script22,function()
  310. function blow(hit)
  311.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  312.  
  313.     if humanoid~=nil then
  314.         humanoid:TakeDamage(25)
  315.     end
  316. end
  317.  
  318.  
  319.  
  320. connection = script.Parent.Touched:connect(blow)
  321.  
  322.  
  323.  
  324. end))
  325. Humanoid23.Name = "Zombie"
  326. Humanoid23.Parent = Model0
  327. Humanoid23.Health = 135
  328. Humanoid23.LeftLeg = Part19
  329. Humanoid23.MaxHealth = 135
  330. Humanoid23.NameOcclusion = Enum.NameOcclusion.NoOcclusion
  331. Humanoid23.RightLeg = Part21
  332. Humanoid23.Torso = Part8
  333. Humanoid23.WalkSpeed = 18
  334. Humanoid23.maxHealth = 135
  335. Hat24.Name = "Millitary Beanie"
  336. Hat24.Parent = Model0
  337. Hat24.AttachmentForward = Vector3.new(0, -0.0995037109, -0.995037138)
  338. Hat24.AttachmentPoint = CFrame.new(0, 0.349999994, 0, 1, 0, -0, 0, 0.995037258, 0.0995037109, 0, -0.0995037258, 0.995037138)
  339. Hat24.AttachmentPos = Vector3.new(0, 0.349999994, 0)
  340. Hat24.AttachmentUp = Vector3.new(0, 0.995037258, -0.0995037258)
  341. Part25.Name = "Handle"
  342. Part25.Parent = Hat24
  343. Part25.CFrame = CFrame.new(20.5216675, 4.65174484, 71.3606796, 1, 3.68560538e-18, 3.68560546e-17, 0, 0.995037258, -0.0995037258, 3.70398773e-17, 0.0995037109, 0.995037138)
  344. Part25.Orientation = Vector3.new(5.71000004, 0, 0)
  345. Part25.Position = Vector3.new(20.5216675, 4.65174484, 71.3606796)
  346. Part25.Rotation = Vector3.new(5.71000004, 0, 0)
  347. Part25.Color = Color3.new(0.768628, 0.156863, 0.109804)
  348. Part25.Size = Vector3.new(1, 1, 1)
  349. Part25.BottomSurface = Enum.SurfaceType.Smooth
  350. Part25.BrickColor = BrickColor.new("Bright red")
  351. Part25.CanCollide = false
  352. Part25.TopSurface = Enum.SurfaceType.Smooth
  353. Part25.brickColor = BrickColor.new("Bright red")
  354. Part25.FormFactor = Enum.FormFactor.Symmetric
  355. Part25.formFactor = Enum.FormFactor.Symmetric
  356. SpecialMesh26.Parent = Part25
  357. SpecialMesh26.MeshId = "http://www.roblox.com/asset/?id=9466401"
  358. SpecialMesh26.Scale = Vector3.new(1, 1.10000002, 0.850000024)
  359. SpecialMesh26.TextureId = "http://www.roblox.com/asset/?id=9466384"
  360. SpecialMesh26.MeshType = Enum.MeshType.FileMesh
  361. Script27.Name = "Control"
  362. Script27.Parent = Model0
  363. table.insert(cors,sandbox(Script27,function()
  364. wait(.1)
  365. local ammo=30 -- How much ammo the Enemy has
  366. local w=.14
  367. local r=false
  368. local t=script.Parent
  369. Spawn(function()
  370.     local c=t:Clone()
  371.     wait(1)
  372.     t.Humanoid.Died:wait()
  373.     wait(3)
  374.     c.Parent=workspace
  375.     c:MakeJoints()
  376.     t:Destroy()
  377. end)
  378. local cf={CFrame.new(.8,.5,.4)*CFrame.Angles(math.rad(270),math.rad(40),0),CFrame.new(-1.2,0.5,0.4)*CFrame.Angles(math.rad(270),math.rad(-5),0)}
  379. local c=LoadLibrary'RbxUtility'.Create
  380. local b1=c'Part'{TopSurface=0;BottomSurface=0;Anchored=true;CanCollide=false;BrickColor=BrickColor.White();Size=Vector3.new(.2,.2,1);c'SpecialMesh'{MeshType=6;Scale=Vector3.new(.2,.2,1)}}
  381. local b2=b1:Clone()
  382. b1.Name,b2.Name='1','2'
  383. local mov=c'Part'{Transparency=1;CanCollide=false;Parent=t;Anchored=true}
  384. local h=t:WaitForChild'Handle'
  385. local function reload(boo)
  386.     if(boo and ammo~=30)or ammo==0 then
  387.         r=true
  388.         if w then
  389.             w=.03
  390.         end
  391.         h.Reload:Play()
  392.         wait(3) -- How long the Enemy reloads
  393.         ammo=30
  394.         if w then
  395.             w=.14
  396.         end
  397.         r=false
  398.     elseif boo then
  399.         wait(.1)
  400.     end
  401. end
  402. local function near()
  403.     local dis,pl=5000,nil -- Range of the Enemy
  404.     for _,v in ipairs(game.Players:GetPlayers())do
  405.         if v.Character and v.Character:FindFirstChild'Humanoid'and v:DistanceFromCharacter(h.Position)<dis then
  406.             dis,pl=v:DistanceFromCharacter(h.Position),v
  407.         end
  408.     end
  409.     if pl then
  410.         return pl.Character:GetModelCFrame(),dis,CFrame.new(pl.Character.Humanoid.WalkToPoint).lookVector
  411.     else
  412.         return nil
  413.     end
  414. end
  415. Spawn(function()
  416.     while true do
  417.         t.Humanoid.Jump=false
  418.         while not w do wait(.1)end
  419.         for i=1,math.random(4,9)do
  420.             wait(w)
  421.         end
  422.     end
  423. end)
  424. Spawn(function()
  425.     while wait(math.random(2,7)/10)do
  426.         local n=near()
  427.         if n and math.random(1,3)==2 or not n then
  428.             mov.CFrame=t.Torso.CFrame+t.Torso.CFrame.lookVector*Vector3.new(math.random(-25,25),0,math.random(-25,25))
  429.         else
  430.             mov.CFrame=n+Vector3.new((math.random(1,2)==1 and 1 or -1)*math.random(25,50),0,(math.random(1,2)==1 and 1 or -1)*math.random(25,50))
  431.         end
  432.         wait(.1)
  433.         t.Zombie:MoveTo(mov.Position,mov)
  434.     end
  435. end)
  436. while true do
  437.     local n,mag,hum=near()
  438.     if n then
  439.         n=n.p
  440.         if not r then
  441.             w=.14
  442.             local dir=h.Position-n
  443.             local tst,_=workspace:FindPartOnRay(Ray.new(t.Torso.Position,(n-t.Torso.Position).Unit*999),t)
  444.             local aim=n+Vector3.new(math.random(-mag*.015,mag*.015),math.random(-mag*.015,mag*.015),math.random(-mag*.015,mag*.015))*(2+math.random())+hum
  445.             if tst and tst.Parent and game.Players:GetPlayerFromCharacter(tst.Parent)then
  446.                 wait(.1)
  447.                 h.Fire:Play()
  448.                 local par,pos=workspace:FindPartOnRay(Ray.new(h.Position,(aim-h.Position).Unit*999),t)
  449.                 if par then
  450.                     local h=par.Parent:FindFirstChild'Humanoid'or par.Parent.Parent:FindFirstChild'Humanoid'
  451.                     if h and h.Health-10>0 then
  452.                         h.Health=h.Health-67.5 -- How much damage the gun inflicts
  453.                     elseif h then
  454.                         h.Health=0
  455.                         h.Parent:BreakJoints()
  456.                     end
  457.                 end
  458.                 ammo=ammo-1
  459.                 mag=(h.Position-pos).magnitude
  460.                 b1.Parent,b2.Parent=t,t
  461.                 b1.CFrame,b2.CFrame=CFrame.new(h.Position:Lerp(pos,.3),pos),CFrame.new(pos:Lerp(h.Position,.175),h.Position) -- Gun Accuracy (ONLY EDIT IF YOU KNOW WHAT TO DO)
  462.                 b1.Mesh.Scale,b2.Mesh.Scale=Vector3.new(.2,.2,mag*.75),Vector3.new(.2,.2,mag/4)
  463.                 Delay(.03,function()b1.Parent=nil wait(.03)b2.Parent=nil end)
  464.             end
  465.             wait(.035) -- How fast the enemy shoots
  466.             if ammo==0 then
  467.                 reload()
  468.             end
  469.         end
  470.     else
  471.         reload(true)
  472.         w=false
  473.     end
  474. end
  475.  
  476. -- Dellkiller123
  477. end))
  478. Part28.Name = "Handle"
  479. Part28.Parent = Model0
  480. Part28.CFrame = CFrame.new(21.3871288, 3.60000825, 69.8140564, -0.087155737, -1.03932174e-09, 0.99619472, -1.19248806e-08, 1, 0, -0.99619472, -1.18795027e-08, -0.087155737)
  481. Part28.Orientation = Vector3.new(0, 95, 0)
  482. Part28.Position = Vector3.new(21.3871288, 3.60000825, 69.8140564)
  483. Part28.Rotation = Vector3.new(-180, 85, 180)
  484. Part28.Color = Color3.new(0.917647, 0.721569, 0.572549)
  485. Part28.Transparency = 1
  486. Part28.Size = Vector3.new(2, 1, 1)
  487. Part28.BrickColor = BrickColor.new("Light orange")
  488. Part28.CanCollide = false
  489. Part28.RightParamA = 0
  490. Part28.RightParamB = 0
  491. Part28.RightSurface = Enum.SurfaceType.Hinge
  492. Part28.brickColor = BrickColor.new("Light orange")
  493. Part28.FormFactor = Enum.FormFactor.Symmetric
  494. Part28.formFactor = Enum.FormFactor.Symmetric
  495. Sound29.Name = "Reload"
  496. Sound29.Parent = Part28
  497. Sound29.SoundId = "http://www.roblox.com/asset/?id=132456279"
  498. Sound29.Volume = 0.10000000149012
  499. Sound30.Name = "Fire"
  500. Sound30.Parent = Part28
  501. Sound30.SoundId = "http://www.roblox.com/asset/?id=139711658"
  502. Sound30.Volume = 1
  503. Script31.Parent = Part28
  504. table.insert(cors,sandbox(Script31,function()
  505. function blow(hit)
  506.     local humanoid = hit.Parent:findFirstChild("Humanoid")
  507.  
  508.     if humanoid~=nil then
  509.         humanoid:TakeDamage(25)
  510.     end
  511. end
  512.  
  513.  
  514.  
  515. connection = script.Parent.Touched:connect(blow)
  516.  
  517.  
  518.  
  519. end))
  520. Script32.Name = "MoneyKill"
  521. Script32.Parent = Model0
  522. table.insert(cors,sandbox(Script32,function()
  523. --[[Edited by kirbycaden to make it easier to work with, original was made by some free modeler. Thank you for using a script
  524. that.]]--
  525.  
  526.  
  527. Stat2 = true --Make this either true or false depending if you want something else to go be increased in leaderstats.
  528.  
  529. StatName = "KOs" --Name of stats.
  530.  
  531. IncreaseValue = 1 --Increase in Money/Cash/Points etc.
  532.  
  533. Stat2Name = "Kills" --SecondStat name
  534.  
  535. IncreaseValue2 = 1 --SecondStat increase value.
  536.  
  537. local Humanoid = script.Parent.Zombie --If your zombies have "Zombie" instead of "Humanoid", make this Zombie.
  538. function PwntX_X()
  539. local tag = Humanoid:findFirstChild("creator")
  540. if tag ~= nil then
  541. if tag.Value ~= nil then
  542. local Leaderstats = tag.Value:findFirstChild("leaderstats")
  543. if Leaderstats ~= nil then
  544. Leaderstats[StatName].Value = Leaderstats[StatName].Value + IncreaseValue --Change Money to the stat that is increased.
  545. if Stat2 == true then
  546. Leaderstats[Stat2Name].Value = Leaderstats[Stat2Name].Value + IncreaseValue2
  547. wait(0.1)
  548. script:remove()
  549. end
  550. end
  551. end
  552. end
  553. end
  554. Humanoid.Died:connect(PwntX_X)
  555. end))
  556. Hat33.Name = "Millitary Beanie"
  557. Hat33.Parent = Model0
  558. Hat33.AttachmentForward = Vector3.new(0, -0.0995037109, -0.995037138)
  559. Hat33.AttachmentPoint = CFrame.new(0, -0.100000001, 0, 1, 0, -0, 0, 0.995037258, 0.0995037109, 0, -0.0995037258, 0.995037138)
  560. Hat33.AttachmentPos = Vector3.new(0, -0.100000001, 0)
  561. Hat33.AttachmentUp = Vector3.new(0, 0.995037258, -0.0995037258)
  562. Part34.Name = "Handle"
  563. Part34.Parent = Hat33
  564. Part34.CFrame = CFrame.new(20.5216675, 5.0995121, 71.4054565, 1, 3.68560538e-18, 3.68560546e-17, 0, 0.995037258, -0.0995037258, 3.70398773e-17, 0.0995037109, 0.995037138)
  565. Part34.Orientation = Vector3.new(5.71000004, 0, 0)
  566. Part34.Position = Vector3.new(20.5216675, 5.0995121, 71.4054565)
  567. Part34.Rotation = Vector3.new(5.71000004, 0, 0)
  568. Part34.Color = Color3.new(0.768628, 0.156863, 0.109804)
  569. Part34.Size = Vector3.new(1, 1, 1)
  570. Part34.BottomSurface = Enum.SurfaceType.Smooth
  571. Part34.BrickColor = BrickColor.new("Bright red")
  572. Part34.CanCollide = false
  573. Part34.TopSurface = Enum.SurfaceType.Smooth
  574. Part34.brickColor = BrickColor.new("Bright red")
  575. Part34.FormFactor = Enum.FormFactor.Symmetric
  576. Part34.formFactor = Enum.FormFactor.Symmetric
  577. SpecialMesh35.Parent = Part34
  578. SpecialMesh35.MeshId = "http://www.roblox.com/asset/?id=76696701"
  579. SpecialMesh35.Scale = Vector3.new(1.26999998, 1.37, 1.26999998)
  580. SpecialMesh35.TextureId = "http://www.roblox.com/asset/?id=121377688"
  581. SpecialMesh35.MeshType = Enum.MeshType.FileMesh
  582. Part36.Parent = Model0
  583. Part36.CFrame = CFrame.new(21.3871288, 4.20000839, 69.8140564, 0.99619472, -1.03932174e-09, 0.087155737, 0, 1, 1.19248806e-08, -0.087155737, -1.18795027e-08, 0.99619472)
  584. Part36.Orientation = Vector3.new(0, 5, 0)
  585. Part36.Position = Vector3.new(21.3871288, 4.20000839, 69.8140564)
  586. Part36.Rotation = Vector3.new(0, 5, 0)
  587. Part36.Color = Color3.new(0.917647, 0.721569, 0.572549)
  588. Part36.Size = Vector3.new(1, 0.200000003, 2)
  589. Part36.BrickColor = BrickColor.new("Light orange")
  590. Part36.CanCollide = false
  591. Part36.RightParamA = 0
  592. Part36.RightParamB = 0
  593. Part36.TopSurface = Enum.SurfaceType.Smooth
  594. Part36.brickColor = BrickColor.new("Light orange")
  595. Part36.FormFactor = Enum.FormFactor.Custom
  596. Part36.formFactor = Enum.FormFactor.Custom
  597. SpecialMesh37.Parent = Part36
  598. SpecialMesh37.MeshId = "http://www.roblox.com/asset/?id=3824749"
  599. SpecialMesh37.Offset = Vector3.new(-0.174999997, -0.600000024, -0.174999997)
  600. SpecialMesh37.Scale = Vector3.new(1.70000005, 1.29999995, 1.10000002)
  601. SpecialMesh37.VertexColor = Vector3.new(0.699999988, 0.699999988, 0.699999988)
  602. SpecialMesh37.TextureId = "http://www.roblox.com/asset/?id=159740858"
  603. SpecialMesh37.MeshType = Enum.MeshType.FileMesh
  604. Script38.Name = "RaceGenerator"
  605. Script38.Parent = Model0
  606. table.insert(cors,sandbox(Script38,function()
  607. colors={"Brick yellow", "Light orange", "Nougat", "Bright orange"}
  608. Color=BrickColor.new(colors[math.random(1,6)])
  609. for i,v in pairs(script.Parent:GetChildren()) do
  610.     if v.Name=='Head' or v.Name=='Right Leg' or v.Name=='Right Arm' or v.Name=='Left Arm' or v.Name=='Left Leg' or v.Name=='Torso' then
  611.         v.BrickColor=Color
  612.     end
  613. end
  614. end))
  615. Pants39.Name = "Pants"
  616. Pants39.Parent = Model0
  617. Pants39.PantsTemplate = "http://www.roblox.com/asset/?id=221961768"
  618. Shirt40.Name = "Shirt"
  619. Shirt40.Parent = Model0
  620. Shirt40.ShirtTemplate = "http://www.roblox.com/asset/?id=221961698"
  621. Script41.Name = "spawnHandler"
  622. Script41.Parent = Model0
  623. table.insert(cors,sandbox(Script41,function()
  624. local NPC = script.Parent
  625. local cln=NPC:Clone()
  626. local Config = NPC.Configuration
  627. local Head, Torso, LArm, RArm, LLeg, RLeg = NPC.Head, NPC.Torso, NPC['Left Arm'], NPC['Right Arm'], NPC['Left Leg'], NPC['Right Leg'];
  628. local Humanoid;
  629. print('Starting bot setup')
  630. -- Preset config
  631. Config.HumanoidReady.Value = false;
  632.  
  633. -- Make sure parts are anchored
  634. function anchor(bool)
  635.     for _,child in pairs(script.Parent:GetChildren()) do
  636.         if child:IsA('Part') and child.Name~='MoveHere' then
  637.             child.Anchored=bool
  638.         end
  639.     end
  640. end
  641.  
  642.  
  643. anchor(true)
  644.  
  645. function Join(MainPart, LegacyPart, Parent, C0, C1)
  646.     local Joint = Instance.new("Motor");
  647.     Joint.Part0 = MainPart
  648.     Joint.Part1 = LegacyPart
  649.     Joint.C0 = C0
  650.     Joint.C1 = C1
  651.     Joint.Parent = Parent -- !Important: Without parenting last, the C1 and C0 will take affect and prematurely move the parts.
  652.     return Joint;
  653. end
  654.  
  655. for _,child in pairs(script.Parent:children()) do
  656.         if child:IsA('Part') then
  657.         Join(Torso,child,Torso,CFrame.new(),child.CFrame:toObjectSpace(Torso.CFrame))
  658.         end
  659.     end
  660. --  -- Build NPC
  661. --  --Join(script.Parent['Right Arm'],script.Parent.Handle, script.Parent['Right Arm'] ,CFrame.new(),script.Parent.Handle.CFrame:toObjectSpace(script.Parent['Right Arm'].CFrame));
  662. --  print('Welded Gun')
  663. --  Join(Torso,script.Parent.Hat1, Torso,CFrame.new(),script.Parent.Hat1.CFrame:toObjectSpace(Torso.CFrame));
  664. --  Join(Torso,script.Parent.Hat2, Torso,CFrame.new(),script.Parent.Hat2.CFrame:toObjectSpace(Torso.CFrame));
  665. --  Join(Torso, Head, Torso, CFrame.new(), Head.CFrame:toObjectSpace(Torso.CFrame));
  666. --  Join(Torso, script.Parent['Left Arm'], Torso, CFrame.new(), script.Parent['Left Arm'].CFrame:toObjectSpace(Torso.CFrame));
  667. --  Join(Torso, script.Parent['Right Arm'], Torso, CFrame.new(), script.Parent['Right Arm'].CFrame:toObjectSpace(Torso.CFrame));   
  668. --  Join(Torso, LLeg, Torso, CFrame.new(0.5,-1,0), CFrame.new(0,1,0));
  669. --  Join(Torso, RLeg, Torso, CFrame.new(-0.5,-1,0), CFrame.new(0,1,0));
  670.     Humanoid = Instance.new("Humanoid");
  671.     Humanoid.Name = "Zombie";
  672.     Humanoid.Parent = NPC;
  673.     Config.HumanoidReady.Value = true;
  674.     wait()
  675.     anchor(false)
  676.    
  677.     Humanoid.Died:connect(function()
  678.         wait(3)
  679.         local np=cln
  680.         cln.Parent=workspace
  681.         NPC:Remove()
  682.     end)
  683. end))
  684. Script42.Name = "Respawn"
  685. Script42.Parent = Model0
  686. table.insert(cors,sandbox(Script42,function()
  687. name="Zombie"
  688.  
  689. robo=script.Parent:clone()
  690.  
  691. while true do
  692.     wait(3)
  693.     if script.Parent.Zombie.Health<1 then
  694.         robot=robo:clone()
  695.         robot.Parent=script.Parent.Parent
  696.         robot:makeJoints()
  697.         script.Parent:remove()
  698.     end
  699. end
  700.        
  701.  
  702.  
  703.  
  704. end))
  705. Script43.Name = "Robot"
  706. Script43.Parent = Model0
  707. table.insert(cors,sandbox(Script43,function()
  708. miked=script.Parent
  709.  
  710. itlh=miked.Torso:findFirstChild("Left Hip")
  711. itlh.Part0=miked.Torso
  712. itlh.Part1=miked:findFirstChild("Left Leg")
  713. itlh.C0=CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  714.  
  715. itrh=miked.Torso:findFirstChild("Right Hip")
  716. itrh.Part0=miked.Torso
  717. itrh.Part1=miked:findFirstChild("Right Leg")
  718. itrh.C0=CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  719.  
  720. itls=miked.Torso:findFirstChild("Left Shoulder")
  721. itls.Part1=miked.Torso
  722. itls.C0=CFrame.new(2, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  723. itls.Part0=miked:findFirstChild("Left Arm")
  724.  
  725. itrs=miked.Torso:findFirstChild("Right Shoulder")
  726. itrs.Part1=miked.Torso
  727. itrs.C0=CFrame.new(-2, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
  728. itrs.Part0=miked:findFirstChild("Right Arm")
  729.  
  730. miked.Head:makeJoints()
  731. ------------------
  732. ------------------
  733.  
  734.  
  735. function waitForChild(parent, childName)
  736.     while true do
  737.         local child = parent:findFirstChild(childName)
  738.         if child then
  739.             return child
  740.         end
  741.         parent.ChildAdded:wait()
  742.     end
  743. end
  744.  
  745. local Figure = script.Parent
  746. local Torso = waitForChild(Figure, "Torso")
  747. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  748. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  749. local RightHip = waitForChild(Torso, "Right Hip")
  750. local LeftHip = waitForChild(Torso, "Left Hip")
  751. local Neck = waitForChild(Torso, "Neck")
  752. local Humanoid = waitForChild(Figure, "Humanoid")
  753. local pose = "Standing"
  754.  
  755. local toolAnim = "None"
  756. local toolAnimTime = 0
  757.  
  758. local isSeated = false
  759.  
  760.  
  761. function onRunning(speed)
  762.     if isSeated then return end
  763.  
  764.     if speed>0 then
  765.         pose = "Running"
  766.     else
  767.         pose = "Standing"
  768.     end
  769. end
  770.  
  771. function onDied()
  772.     pose = "Dead"
  773. end
  774.  
  775. function onJumping()
  776.     isSeated = false
  777.     pose = "Jumping"
  778. end
  779.  
  780. function onClimbing()
  781.     pose = "Climbing"
  782. end
  783.  
  784. function onGettingUp()
  785.     pose = "GettingUp"
  786. end
  787.  
  788. function onFreeFall()
  789.     pose = "FreeFall"
  790. end
  791.  
  792. function onDancing()
  793.     pose = "Dancing"
  794. end
  795.  
  796. function onFallingDown()
  797.     pose = "FallingDown"
  798. end
  799.  
  800. function onSeated()
  801.     isSeated = true
  802.     pose = "Seated"
  803. end
  804.  
  805.  
  806.  
  807. function moveJump()
  808.     RightShoulder.MaxVelocity = 0.5
  809.     LeftShoulder.MaxVelocity = 0.5
  810.     RightShoulder.DesiredAngle = -3.14
  811.     LeftShoulder.DesiredAngle = -3.14
  812.     RightHip.DesiredAngle = 0
  813.     LeftHip.DesiredAngle = 0
  814. end
  815.  
  816. function moveFreeFall()
  817.     RightShoulder.MaxVelocity = 0.5
  818.     LeftShoulder.MaxVelocity = 0.5
  819.     RightShoulder.DesiredAngle = -1
  820.     LeftShoulder.DesiredAngle = -1
  821.     RightHip.DesiredAngle = 0
  822.     LeftHip.DesiredAngle = 0
  823. end
  824.  
  825. function moveFloat()
  826.     RightShoulder.MaxVelocity = 0.5
  827.     LeftShoulder.MaxVelocity = 0.5
  828.     RightShoulder.DesiredAngle = -1.57
  829.     LeftShoulder.DesiredAngle = 1.57
  830.     RightHip.DesiredAngle = 1.57
  831.     LeftHip.DesiredAngle = -1.57
  832. end
  833.  
  834. function moveBoogy()
  835. while pose=="Boogy" do
  836.     wait(.5)
  837.     RightShoulder.MaxVelocity = 1
  838.     LeftShoulder.MaxVelocity = 1
  839.     RightShoulder.DesiredAngle = -3.14
  840.     LeftShoulder.DesiredAngle = 0
  841.     RightHip.DesiredAngle = 1.57
  842.     LeftHip.DesiredAngle = 0
  843.     wait(.5)
  844.     RightShoulder.MaxVelocity = 1
  845.     LeftShoulder.MaxVelocity = 1
  846.     RightShoulder.DesiredAngle = 0
  847.     LeftShoulder.DesiredAngle = -3.14
  848.     RightHip.DesiredAngle = 0
  849.     LeftHip.DesiredAngle = 1.57
  850. end
  851. end
  852.  
  853. function moveZombie()
  854.     RightShoulder.MaxVelocity = 0.5
  855.     LeftShoulder.MaxVelocity = 0.5
  856.     RightShoulder.DesiredAngle = -1.57
  857.     LeftShoulder.DesiredAngle = 1.57
  858.     RightHip.DesiredAngle = 0
  859.     LeftHip.DesiredAngle = 0
  860. end
  861.  
  862. function movePunch()
  863.     script.Parent.Torso.Anchored=true
  864.     RightShoulder.MaxVelocity = 60
  865.     LeftShoulder.MaxVelocity = 0.5
  866.     RightShoulder.DesiredAngle = -1.57
  867.     LeftShoulder.DesiredAngle = 0
  868.     RightHip.DesiredAngle = 0
  869.     LeftHip.DesiredAngle = 0
  870. wait(1)
  871. script.Parent.Torso.Anchored=false
  872. pose="Standing"
  873.  
  874. end
  875.  
  876. function moveKick()
  877.     RightShoulder.MaxVelocity = 0.5
  878.     LeftShoulder.MaxVelocity = 0.5
  879.     RightShoulder.DesiredAngle = 0
  880.     LeftShoulder.DesiredAngle = 0
  881.     RightHip.MaxVelocity = 40
  882.     RightHip.DesiredAngle = 1.57
  883.     LeftHip.DesiredAngle = 0
  884. wait(1)
  885. pose="Standing"
  886.  
  887. end
  888.  
  889. function moveFly()
  890.     RightShoulder.MaxVelocity = 0.5
  891.     LeftShoulder.MaxVelocity = 0.5
  892.     RightShoulder.DesiredAngle = 0
  893.     LeftShoulder.DesiredAngle = 0
  894.     RightHip.MaxVelocity = 40
  895.     RightHip.DesiredAngle = 1.57
  896.     LeftHip.DesiredAngle = 0
  897. wait(1)
  898. pose="Standing"
  899.  
  900. end
  901.  
  902.  
  903. function moveClimb()
  904.     RightShoulder.MaxVelocity = 0.5
  905.     LeftShoulder.MaxVelocity = 0.5
  906.     RightShoulder.DesiredAngle = -3.14
  907.     LeftShoulder.DesiredAngle = 3.14
  908.     RightHip.DesiredAngle = 0
  909.     LeftHip.DesiredAngle = 0
  910. end
  911.  
  912. function moveSit()
  913.     RightShoulder.MaxVelocity = 0.15
  914.     LeftShoulder.MaxVelocity = 0.15
  915.     RightShoulder.DesiredAngle = -3.14 /2
  916.     LeftShoulder.DesiredAngle = -3.14 /2
  917.     RightHip.DesiredAngle = 3.14 /2
  918.     LeftHip.DesiredAngle = -3.14 /2
  919. end
  920.  
  921. function getTool()
  922.    
  923.     kidTable = Figure:children()
  924.     if (kidTable ~= nil) then
  925.         numKids = #kidTable
  926.         for i=1,numKids do
  927.             if (kidTable[i].className == "Tool") then return kidTable[i] end
  928.         end
  929.     end
  930.    
  931.     return nil
  932. end
  933.  
  934. function getToolAnim(tool)
  935.  
  936.     c = tool:children()
  937.     for i=1,#c do
  938.         if (c[i].Name == "toolanim" and c[i].className == "StringValue") then
  939.             return c[i]
  940.         end
  941.     end
  942.     return nil
  943. end
  944.  
  945. function animateTool()
  946.    
  947.     if (toolAnim == "None") then
  948.         RightShoulder.DesiredAngle = -1.57
  949.         return
  950.     end
  951.  
  952.     if (toolAnim == "Slash") then
  953.         RightShoulder.MaxVelocity = 0.5
  954.         RightShoulder.DesiredAngle = 0
  955.         return
  956.     end
  957.  
  958.     if (toolAnim == "Lunge") then
  959.         RightShoulder.MaxVelocity = 0.5
  960.         LeftShoulder.MaxVelocity = 0.5
  961.         RightHip.MaxVelocity = 0.5
  962.         LeftHip.MaxVelocity = 0.5
  963.         RightShoulder.DesiredAngle = -1.57
  964.         LeftShoulder.DesiredAngle = 1.0
  965.         RightHip.DesiredAngle = 1.57
  966.         LeftHip.DesiredAngle = 1.0
  967.         return
  968.     end
  969. end
  970.  
  971. function move(time)
  972.     local amplitude
  973.     local frequency
  974.  
  975.     if (pose == "Jumping") then
  976.         moveJump()
  977.         return
  978.     end
  979.  
  980.     if (pose == "Zombie") then
  981.         moveZombie()
  982.         return
  983.     end
  984.  
  985.     if (pose == "Boogy") then
  986.         moveBoogy()
  987.         return
  988.     end
  989.  
  990.     if (pose == "Float") then
  991.         moveFloat()
  992.         return
  993.     end
  994.  
  995.     if (pose == "Punch") then
  996.         movePunch()
  997.         return
  998.     end
  999.  
  1000.     if (pose == "Kick") then
  1001.         moveKick()
  1002.         return
  1003.     end
  1004.  
  1005.     if (pose == "Fly") then
  1006.         moveFly()
  1007.         return
  1008.     end
  1009.  
  1010.     if (pose == "FreeFall") then
  1011.         moveFreeFall()
  1012.         return
  1013.     end
  1014.  
  1015.     if (pose == "Climbing") then
  1016.         moveClimb()
  1017.         return
  1018.     end
  1019.  
  1020.     if (pose == "Seated") then
  1021.         moveSit()
  1022.         return
  1023.     end
  1024.  
  1025.         amplitude = 0.1
  1026.         frequency = 1
  1027.  
  1028.     RightShoulder.MaxVelocity = 0.15
  1029.     LeftShoulder.MaxVelocity = 0.15
  1030.     if (pose == "Running") then
  1031.         amplitude = 1
  1032.         frequency = 9
  1033.     elseif (pose == "Dancing") then
  1034.         amplitude = 2
  1035.         frequency = 16
  1036.     end
  1037.  
  1038.  
  1039.     desiredAngle = amplitude * math.sin(time*frequency)
  1040.     if pose~="Dancing" then
  1041.         RightShoulder.DesiredAngle = -desiredAngle
  1042.         LeftShoulder.DesiredAngle = desiredAngle
  1043.         RightHip.DesiredAngle = -desiredAngle
  1044.         LeftHip.DesiredAngle = -desiredAngle
  1045.     else
  1046.         RightShoulder.DesiredAngle = desiredAngle
  1047.         LeftShoulder.DesiredAngle = desiredAngle
  1048.         RightHip.DesiredAngle = -desiredAngle
  1049.         LeftHip.DesiredAngle = -desiredAngle
  1050.     end
  1051.        
  1052.  
  1053.  
  1054.     local tool = getTool()
  1055.  
  1056.     if tool ~= nil then
  1057.    
  1058.         animStringValueObject = getToolAnim(tool)
  1059.  
  1060.         if animStringValueObject ~= nil then
  1061.             toolAnim = animStringValueObject.Value
  1062.             -- message recieved, delete StringValue
  1063.             animStringValueObject.Parent = nil
  1064.             toolAnimTime = time + .3
  1065.         end
  1066.  
  1067.         if time > toolAnimTime then
  1068.             toolAnimTime = 0
  1069.             toolAnim = "None"
  1070.         end
  1071.  
  1072.         animateTool()
  1073.  
  1074.        
  1075.     else
  1076.         toolAnim = "None"
  1077.         toolAnimTime = 0
  1078.     end
  1079. end
  1080.  
  1081.  
  1082. -- connect events
  1083. -----------------------------------------------------------------------------------------------------------------------
  1084.  
  1085. function unequip()
  1086.     local items=script.Parent:children()
  1087.     for i=1, #items do
  1088.         if items[i].className=="Tool" then items[i]:remove() end
  1089.     end
  1090. end
  1091.  
  1092. function onChatted(msg, recipient)
  1093.     msg = string.lower(msg)
  1094.  
  1095.     if string.match(msg, string.lower(script.Parent.Name))~=nil or string.match(msg, "everyone") then
  1096.         if string.match(msg, "equip") then
  1097.             if game.Workspace:findFirstChild("Hub") then
  1098.                 if string.match(msg, "rocket") then unequip()
  1099.                     game.Workspace.Hub.Rocket:clone().Parent=script.Parent
  1100.                 elseif string.match(msg, "slingshot") then unequip()
  1101.                     game.Workspace.Hub.Slingshot:clone().Parent=script.Parent
  1102.                 elseif string.match(msg, "sword") then unequip()
  1103.                     game.Workspace.Hub.Sword:clone().Parent=script.Parent
  1104.                 elseif string.match(msg, "pbg") then unequip()
  1105.                     game.Workspace.Hub.PBG:clone().Parent=script.Parent
  1106.                 elseif string.match(msg, "superball") then unequip()
  1107.                     game.Workspace.Hub.Superball:clone().Parent=script.Parent
  1108.                 elseif string.match(msg, "trowel") then unequip()
  1109.                     game.Workspace.Hub.Trowel:clone().Parent=script.Parent
  1110.                 elseif string.match(msg, "bomb") then unequip()
  1111.                     game.Workspace.Hub.Bomb:clone().Parent=script.Parent
  1112.                 end
  1113.             end
  1114.         end
  1115.         if string.match(msg, "unequip") then unequip() end
  1116.         if string.match(msg, "run") then onRunning(1) end
  1117.         if string.match(msg, "climb") then onClimbing() end
  1118.         if string.match(msg, "jump") then onJumping() end
  1119.         if string.match(msg, "zombie") then pose="Zombie" end
  1120.         if string.match(msg, "disco") then pose="Boogy" end
  1121.         if string.match(msg, "float") then pose="Float" end
  1122.         if string.match(msg, "punch") then pose="Punch" end
  1123.         if string.match(msg, "kick") then pose="Kick" end
  1124.         if string.match(msg, "fly") then pose="Fly" end
  1125.         if string.match(msg, "heal") then script.Parent.Humanoid.Health=script.Parent.Humanoid.MaxHealth end
  1126.         if string.match(msg, "defend") then defence() end
  1127.         if string.match(msg, "stop") then pose="Standing"; proxkill=false; following=false; stopmoving() end
  1128.         if string.match(msg, "go home") then following=false; gohome() end
  1129.         if string.match(msg, "follow") then
  1130.             if string.match(msg, "all") then
  1131.                 followany()
  1132.             else
  1133.                 local egg=game.Players:children()
  1134.                 for i=1, #egg do
  1135.                     if string.match(msg, string.lower(egg[i].Name)) then
  1136.                         follow(egg[i].Name)
  1137.                         return
  1138.                     end
  1139.                 end
  1140.             end
  1141.         end
  1142.         if string.match(msg, "kill") then
  1143.             if string.match(msg, "all") then
  1144.                 attackany()
  1145.             else
  1146.                 local egg=game.Players:children()
  1147.                 for i=1, #egg do
  1148.                     if string.match(msg, string.lower(egg[i].Name)) then
  1149.                         attack(egg[i].Name)
  1150.                         return
  1151.                     end
  1152.                 end
  1153.             end
  1154.         end
  1155.  
  1156.     end
  1157. end
  1158.  
  1159. if game.Players.NumPlayers>1 then
  1160.     x=game.Players:children()
  1161.    
  1162.     for i=1, #x do
  1163.         if script.Parent:findFirstChild("Commander")~=nil then
  1164.             if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then
  1165.                 local ch=script.Parent.Commander:children()
  1166.                 for i=1, #ch do
  1167.                     if string.lower(ch[i].Name)==string.lower(x[i].Name) then
  1168.                         x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  1169.                     end
  1170.                 end
  1171.             elseif string.lower(script.Parent.Commander.Value)==string.lower(x[i].Name) then
  1172.                 x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  1173.             end
  1174.         else
  1175.             x[i].Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  1176.         end
  1177.     end
  1178. end
  1179.  
  1180.  
  1181. function onPlayerEntered(Player)
  1182.     while Player.Name==nil do
  1183.         wait(2)
  1184.     end
  1185.     if script.Parent:findFirstChild("Commander")~=nil then
  1186.         if script.Parent.Commander:children()~=nil or script.Parent.Commander:children()>0 then
  1187.             local ch=script.Parent.Commander:children()
  1188.             for i=1, #ch do
  1189.                 if string.lower(ch[i].Name)==string.lower(Player.Name) then
  1190.                     Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  1191.                 end
  1192.             end
  1193.         elseif string.lower(script.Parent.Commander.Value)==string.lower(Player.Name) then
  1194.             Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  1195.         end
  1196.     else
  1197.         Player.Chatted:connect(function(msg, recipient) onChatted(msg, recipient) end)
  1198.     end
  1199. end
  1200.  
  1201. game.Players.ChildAdded:connect(onPlayerEntered)
  1202.  
  1203.  
  1204.  
  1205. -----------------------------------------------------------------------------------------------------------------------
  1206. -----------------------------------------------------------------------------------------------------------------------
  1207. -----------------------------------------------------------------------------------------------------------------------
  1208. -----------------------------------------------------------------------------------------------------------------------
  1209. -----------------------------------------------------------------------------------------------------------------------
  1210. -----------------------------------------------------------------------------------------------------------------------
  1211. -----------------------------------------------------------------------------------------------------------------------
  1212. -----------------------------------------------------------------------------------------------------------------------
  1213. -----------------------------------------------------------------------------------------------------------------------
  1214. -----------------------------------------------------------------------------------------------------------------------
  1215. -----------------------------------------------------------------------------------------------------------------------
  1216. -----------------------------------------------------------------------------------------------------------------------
  1217. dist=20
  1218.  
  1219. function followany()
  1220. following=true
  1221.     while following==true do
  1222.  
  1223.         local ch=game.Players:children()
  1224.         for i=1, #ch do
  1225.             local l=game.Workspace:findFirstChild(ch[i].Name)
  1226.             if l~=nil then
  1227.                 local s=l.Torso
  1228.                 local p=l.Torso.Position
  1229.                 local q=script.Parent.Torso.Position
  1230.                 local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  1231.                 if smallest==nil then
  1232.                     smallest=d
  1233.                     target=s
  1234.                 elseif d<smallest then
  1235.                     smallest=d
  1236.                     target=s
  1237.                 end
  1238.             end
  1239.         end
  1240.  
  1241.         if smallest==nil then stopmoving() return end
  1242.        
  1243.         if smallest>6*dist then return end
  1244.        
  1245.         script.Parent.Humanoid:MoveTo(target.Position, target)
  1246.  
  1247.         wait(0.5)
  1248.         for i=1, 6 do
  1249.             if target.Parent.Humanoid.Health<1 then stopmoving() else   wait(0.5) end
  1250.         end
  1251.     end
  1252. end
  1253.  
  1254.  
  1255.  
  1256. function gohome()
  1257.     script.Parent.Humanoid:MoveTo(Vector3.new(0,0,0), game.Workspace.Bases.Base)
  1258. end
  1259. function stopmoving()
  1260.     script.Parent.Humanoid:MoveTo(script.Parent.Torso.Position, script.Parent.Torso)
  1261. end
  1262.  
  1263. function follow(name)
  1264.     following=true
  1265.  
  1266.     local p=game.Workspace:findFirstChild(name)
  1267.     if p==nil then return end
  1268.     while following==true do   
  1269.         script.Parent.Humanoid:MoveTo(p.Torso.Position, p.Torso)
  1270.         wait(0.5)
  1271.         for i=1, 3 do
  1272.             if p.Humanoid.Health<1 then following=false; stopmoving() return end
  1273.             wait(0.5)
  1274.         end
  1275.     end
  1276. end
  1277.  
  1278. function attack(name)
  1279.     if script.Parent:findFirstChild("Sword")~=nil then 
  1280.         following=true
  1281.         local p=game.Workspace:findFirstChild(name)
  1282.         if p==nil then return end
  1283.         while following==true do
  1284.             script.Parent.Humanoid:MoveTo(p.Torso.Position, p.Torso)
  1285.             wait(0.5)
  1286.             for i=1, 3 do
  1287.                 if p.Humanoid.Health<1 then following=false; stopmoving() return end
  1288.                 local l=p.Torso.Position
  1289.                 local q=script.Parent.Torso.Position
  1290.                 local d=math.sqrt( ((l.x-q.x)^2)+((l.y-q.y)^2)+((l.z-q.z)^2) )
  1291.                 if d<10 then
  1292.                     script.Parent.Humanoid:MoveTo(p.Torso.Position, p.Torso); slash()
  1293.                     if (q.y-l.y)>3 and (q.y-l.y)<7 then
  1294.                         script.Parent.Humanoid:MoveTo(p.Torso.Position+Vector3.new(math.random(-4,4),0,math.random(-4,4)), p.Torso);
  1295.                     end
  1296.                 end
  1297.                 wait(1)
  1298.             end
  1299.         end
  1300.     end
  1301. end
  1302.  
  1303. function attackany()
  1304. if script.Parent:findFirstChild("Sword")~=nil then 
  1305.  
  1306.     following=true
  1307.         while following==true do
  1308.  
  1309.             local ch=game.Players:children()
  1310.             for i=1, #ch do
  1311.                 local l=game.Workspace:findFirstChild(ch[i].Name)
  1312.                 if l~=nil then
  1313.                     local s=l.Torso
  1314.                     local p=l.Torso.Position
  1315.                     local q=script.Parent.Torso.Position
  1316.                     local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  1317.                     if smallest==nil then
  1318.                         smallest=d
  1319.                         target=s
  1320.                     elseif d<smallest then
  1321.                         smallest=d
  1322.                         target=s
  1323.                     end
  1324.                 end
  1325.             end
  1326.  
  1327.             if smallest==nil then stopmoving() return end
  1328.            
  1329.             if smallest>6*dist then return end
  1330.            
  1331.             script.Parent.Humanoid:MoveTo(target.Position, target)
  1332.  
  1333.             if smallest<10 then
  1334.                 slash()
  1335.             end
  1336.             if target.Parent==nil then stopmoving() return end
  1337.             wait(0.5)
  1338.             for i=1, 3 do
  1339.                 if target.Parent.Humanoid.Health<1 then
  1340.                     stopmoving()
  1341.                 else
  1342.                     local p=target.Position
  1343.                     local q=script.Parent.Torso.Position
  1344.                     local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  1345.                     if d<10 then
  1346.                         script.Parent.Humanoid:MoveTo(target.Position, target); slash()
  1347.                         if (q.y-p.y)>3 and (q.y-p.y)<7 then
  1348.                             script.Parent.Humanoid:MoveTo(p.Torso.Position+Vector3.new(math.random(-4,4),0,math.random(-4,4)), p.Torso);
  1349.                         end
  1350.                     end
  1351.                     wait(1)
  1352.                 end
  1353.             end
  1354.         end
  1355.     end
  1356. end
  1357.  
  1358.  
  1359. function patrol()
  1360.     if points==nil then
  1361.         points=0
  1362.         if game.Workspace:findFirstChild("pp1")~=nil then
  1363.         pp1=game.Workspace:findFirstChild("pp1")
  1364.         local points=points+1
  1365.             if game.Workspace:findFirstChild("pp2")~=nil then
  1366.             pp2=game.Workspace:findFirstChild("pp2")
  1367.         local points=points+1
  1368.                 if game.Workspace:findFirstChild("pp3")~=nil then
  1369.                 pp3=game.Workspace:findFirstChild("pp3")
  1370.         local points=points+1
  1371.                     if game.Workspace:findFirstChild("pp4")~=nil then
  1372.                     pp4=game.Workspace:findFirstChild("pp4")
  1373.         local points=points+1
  1374.                         if game.Workspace:findFirstChild("pp5")~=nil then
  1375.                         pp5=game.Workspace:findFirstChild("pp5")
  1376.         local points=points+1
  1377.                             if game.Workspace:findFirstChild("pp6")~=nil then
  1378.                             pp6=game.Workspace:findFirstChild("pp6")
  1379.         local points=points+1
  1380.                                 if game.Workspace:findFirstChild("pp7")~=nil then
  1381.                                 pp7=game.Workspace:findFirstChild("pp7")
  1382.         local points=points+1
  1383.                                     if game.Workspace:findFirstChild("pp8")~=nil then
  1384.                                     pp8=game.Workspace:findFirstChild("pp8")
  1385.         local points=points+1
  1386.                                         if game.Workspace:findFirstChild("pp9")~=nil then
  1387.                                         pp9=game.Workspace:findFirstChild("pp9")
  1388.         local points=points+1
  1389.                                         end
  1390.                                     end
  1391.                                 end
  1392.                             end
  1393.                         end
  1394.                     end
  1395.                 end
  1396.             end
  1397.         end
  1398.     end
  1399.  
  1400.     if points<1 then return end
  1401.     patrolling=true
  1402.     local time=2
  1403.     if points==1 then return end
  1404.     if points>1 then
  1405.         while patrolling==true do
  1406.             script.Parent.Humanoid:MoveTo(pp1.Position, pp1)
  1407.             wait(time)
  1408.             script.Parent.Humanoid:MoveTo(pp2.Position, pp2)
  1409.             wait(time)
  1410.             if points>2 then
  1411.                 script.Parent.Humanoid:MoveTo(pp3.Position, pp3)
  1412.                 wait(time)
  1413.                 if points>3 then
  1414.                     script.Parent.Humanoid:MoveTo(pp4.Position, pp4)
  1415.                     wait(time)
  1416.                     if points>4 then
  1417.                         script.Parent.Humanoid:MoveTo(pp5.Position, pp5)
  1418.                         wait(time)
  1419.                         if points>5 then
  1420.                             script.Parent.Humanoid:MoveTo(pp6.Position, pp6)
  1421.                             wait(time)
  1422.                             if points>6 then
  1423.                                 script.Parent.Humanoid:MoveTo(pp7.Position, pp7)
  1424.                                 wait(time)
  1425.                                 if points>7 then
  1426.                                     script.Parent.Humanoid:MoveTo(pp8.Position, pp8)
  1427.                                     wait(time)
  1428.                                     if points>8 then
  1429.                                         script.Parent.Humanoid:MoveTo(pp9.Position, pp9)
  1430.                                         wait(time)
  1431.                                     end
  1432.                                 end
  1433.                             end
  1434.                         end
  1435.                     end
  1436.                 end
  1437.             end
  1438.         end
  1439.     end
  1440. end
  1441.  
  1442.  
  1443. function goto(pos,part)
  1444. while true do
  1445. end
  1446. end
  1447.  
  1448.  
  1449. function slash()
  1450.     for i=1, 3 do
  1451.         wait(.3)
  1452.         RightShoulder.MaxVelocity = 2
  1453.         LeftShoulder.MaxVelocity = 1
  1454.         RightShoulder.DesiredAngle = -2.14
  1455.         LeftShoulder.DesiredAngle = 0
  1456.         RightHip.DesiredAngle = 0
  1457.         LeftHip.DesiredAngle = 0
  1458.         wait(.2)
  1459.         RightShoulder.MaxVelocity = 2
  1460.         LeftShoulder.MaxVelocity = 1
  1461.         RightShoulder.DesiredAngle = 0
  1462.         LeftShoulder.DesiredAngle = 0
  1463.         RightHip.DesiredAngle = 0
  1464.         LeftHip.DesiredAngle = 0
  1465.     end
  1466. end
  1467.  
  1468. function defence()
  1469.     proxkill=true
  1470.     while proxkill==true do
  1471.         local ch=game.Players:children()
  1472.         for i=1, #ch do
  1473.             local p=game.Workspace:findFirstChild(ch[i].Name)
  1474.             if p~=nil then
  1475.                 local p=p.Torso.Position
  1476.                 local q=script.Parent.Torso.Position
  1477.                 local d=math.sqrt( ((p.x-q.x)^2)+((p.y-q.y)^2)+((p.z-q.z)^2) )
  1478.                 if d<dist and d>8 then
  1479.                     local ex=Instance.new("Explosion")
  1480.                     ex.Position=p
  1481.                     ex.Parent=game.Workspace
  1482.                 end
  1483.             end    
  1484.         end
  1485.         wait(1)
  1486.     end
  1487. end
  1488.  
  1489.  
  1490.  
  1491.  
  1492. -----------------------------------------------------------------------------------------------------------------------
  1493. -----------------------------------------------------------------------------------------------------------------------
  1494. -----------------------------------------------------------------------------------------------------------------------
  1495. -----------------------------------------------------------------------------------------------------------------------
  1496. -----------------------------------------------------------------------------------------------------------------------
  1497. -----------------------------------------------------------------------------------------------------------------------
  1498. -----------------------------------------------------------------------------------------------------------------------
  1499. -----------------------------------------------------------------------------------------------------------------------
  1500. -----------------------------------------------------------------------------------------------------------------------
  1501. -----------------------------------------------------------------------------------------------------------------------
  1502. -----------------------------------------------------------------------------------------------------------------------
  1503. -----------------------------------------------------------------------------------------------------------------------
  1504.  
  1505.  
  1506. Humanoid.Died:connect(onDied)
  1507. Humanoid.Running:connect(onRunning)
  1508. Humanoid.Jumping:connect(onJumping)
  1509. Humanoid.Climbing:connect(onClimbing)
  1510. Humanoid.GettingUp:connect(onGettingUp)
  1511. Humanoid.FreeFalling:connect(onFreeFall)
  1512. Humanoid.FallingDown:connect(onFallingDown)
  1513. Humanoid.Seated:connect(onSeated)
  1514.  
  1515.  
  1516. --[[
  1517.  
  1518. function newSound(id)
  1519.     local sound = Instance.new("Sound")
  1520.     sound.SoundId = id
  1521.     sound.Parent = script.Parent.Head
  1522.     return sound
  1523. end
  1524.  
  1525.  
  1526. local sDied = newSound("rbxasset://sounds/uuhhh.wav")
  1527. local sFallingDown = newSound("rbxasset://sounds/splat.wav")
  1528. local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
  1529. local sGettingUp = newSound("rbxasset://sounds/hit.wav")
  1530. local sJumping = newSound("rbxasset://sounds/button.wav")
  1531. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
  1532. sRunning.Looped = true
  1533.  
  1534. local Figure = script.Parent
  1535. local Head = waitForChild(Figure, "Head")
  1536. local Humanoid = waitForChild(Figure, "Humanoid")
  1537.  
  1538.  
  1539. function onDied()
  1540.     sDied:play()
  1541. end
  1542.  
  1543. function onState(state, sound)
  1544.     if state then
  1545.         sound:play()
  1546.     else
  1547.         sound:pause()
  1548.     end
  1549. end
  1550.  
  1551. function onRunning(speed)
  1552.     if speed>0 then
  1553.         sRunning:play()
  1554.     else
  1555.         sRunning:pause()
  1556.     end
  1557. end
  1558.  
  1559.  
  1560. Humanoid.Died:connect(onDied)
  1561. Humanoid.Running:connect(onRunning)
  1562. Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
  1563. Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
  1564. Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
  1565. Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
  1566. --]]
  1567.  
  1568. local nextTime = 0
  1569. local runService = game:service("RunService");
  1570.  
  1571. while Figure.Parent~=nil do
  1572.     time = runService.Stepped:wait()
  1573.     if time > nextTime then
  1574.         move(time)
  1575.         nextTime = time + 0.1
  1576.     end
  1577. end
  1578.  
  1579. end))
  1580. for i,v in pairs(mas:GetChildren()) do
  1581.     v.Parent = workspace
  1582.     pcall(function() v:MakeJoints() end)
  1583. end
  1584. mas:Destroy()
  1585. for i,v in pairs(cors) do
  1586.     spawn(function()
  1587.         pcall(v)
  1588.     end)
  1589. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement