sawgamer1

Untitled

Jan 5th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.71 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  3. local RealPlayer = Player
  4. do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end,__call=function(self,...)local t=rawget(self,"_RealService")if t then return t(...)end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return self[t]end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;x.RunService=v({RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")setmetatable(x,{__index=function(self,t)return r:GetService(t)or typeof(r[t])=="function"and function(m,...)return r[t](r,...)end or r[t]end,__newindex=s.__newindex,__call=s.__call})game,owner=x,x.Players.LocalPlayer end
  5.  
  6.  
  7.  
  8. --Converted with ttyyuu12345's model to script plugin v4
  9. function sandbox(var,func)
  10. local env = getfenv(func)
  11. local newenv = setmetatable({},{
  12. __index = function(self,k)
  13. if k=="script" then
  14. return var
  15. else
  16. return env[k]
  17. end
  18. end,
  19. })
  20. setfenv(func,newenv)
  21. return func
  22. end
  23. cors = {}
  24. mas = Instance.new("Model",game:GetService("Lighting"))
  25. Model0 = Instance.new("Model")
  26. Script1 = Instance.new("Script")
  27. Script2 = Instance.new("Script")
  28. Model3 = Instance.new("Model")
  29. Part4 = Instance.new("Part")
  30. Part5 = Instance.new("Part")
  31. Part6 = Instance.new("Part")
  32. Script7 = Instance.new("Script")
  33. Part8 = Instance.new("Part")
  34. Part9 = Instance.new("Part")
  35. Part10 = Instance.new("Part")
  36. Part11 = Instance.new("Part")
  37. Part12 = Instance.new("Part")
  38. Part13 = Instance.new("Part")
  39. SpecialMesh14 = Instance.new("SpecialMesh")
  40. Decal15 = Instance.new("Decal")
  41. Script16 = Instance.new("Script")
  42. Model0.Parent = mas
  43. Script1.Name = "Tutorial"
  44. Script1.Parent = Model0
  45. table.insert(cors,sandbox(Script1,function()
  46. -- Hello everyone, ImaBoss838 here. This is a small read me/tutorial on how to set up Redditor's pathfinding zombie ai.
  47.  
  48. -- Lets start off with the basics:
  49.  
  50. -- *You can edit the detection distance on the AI in the controller script, i've highlighted the line.
  51. -- *The "Spawner" script is just kind of a duplicator script, it duplicates the zombie and respawns it.
  52. -- *Inside the "Spawner" script there is the model, aka, the zombie AI. You can copy it and paste it as you like.
  53. -- *Inside the Zombie AI there is a script, edit the stats there. (The ones I tell you that you can edit, its marked in the script)
  54.  
  55. -- Now, with that out of the way, its not really much else to say, right now you cant tweak as much on this AI, unless you know what you're doing.
  56. -- Happy zombie slaying!
  57. end))
  58. Script2.Name = "Spawner"
  59. Script2.Parent = Model0
  60. table.insert(cors,sandbox(Script2,function()
  61. local model = script:GetChildren()[1]:clone()
  62.  
  63. script.ChildRemoved:connect(function()
  64. for i = 1, 25 - #script:GetChildren() do
  65. local m = model:clone()
  66. m.Parent = script
  67. m:MoveTo(Vector3.new(math.random() * 200-100, 5, math.random() * 200-100))
  68. end
  69. end)
  70. script:GetChildren()[1]:Destroy()
  71. end))
  72. Model3.Name = "Zombie A.I"
  73. Model3.Parent = Script2
  74. Part4.Name = "Right Leg"
  75. Part4.Parent = Model3
  76. Part4.CFrame = CFrame.new(-12.199996, 1.90001094, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  77. Part4.Position = Vector3.new(-12.199996, 1.90001094, -16.1000061)
  78. Part4.Color = Color3.new(0, 0.560784, 0.611765)
  79. Part4.Transparency = 1
  80. Part4.Size = Vector3.new(1, 1, 1)
  81. Part4.Anchored = true
  82. Part4.BottomSurface = Enum.SurfaceType.Smooth
  83. Part4.BrickColor = BrickColor.new("Bright bluish green")
  84. Part4.Locked = true
  85. Part4.TopSurface = Enum.SurfaceType.Smooth
  86. Part4.brickColor = BrickColor.new("Bright bluish green")
  87. Part4.FormFactor = Enum.FormFactor.Custom
  88. Part4.formFactor = Enum.FormFactor.Custom
  89. Part5.Name = "Torso"
  90. Part5.Parent = Model3
  91. Part5.CFrame = CFrame.new(-12.199996, 3.00001192, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  92. Part5.Position = Vector3.new(-12.199996, 3.00001192, -16.1000061)
  93. Part5.Color = Color3.new(0.388235, 0.372549, 0.384314)
  94. Part5.Transparency = 1
  95. Part5.Size = Vector3.new(2, 2, 2)
  96. Part5.Anchored = true
  97. Part5.BottomSurface = Enum.SurfaceType.Smooth
  98. Part5.BrickColor = BrickColor.new("Dark stone grey")
  99. Part5.Friction = 0
  100. Part5.Locked = true
  101. Part5.TopSurface = Enum.SurfaceType.Smooth
  102. Part5.brickColor = BrickColor.new("Dark stone grey")
  103. Part5.FormFactor = Enum.FormFactor.Symmetric
  104. Part5.formFactor = Enum.FormFactor.Symmetric
  105. Part5.Shape = Enum.PartType.Ball
  106. Part6.Name = "Head"
  107. Part6.Parent = Model3
  108. Part6.CFrame = CFrame.new(-12.199996, 4.50000381, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  109. Part6.Position = Vector3.new(-12.199996, 4.50000381, -16.1000061)
  110. Part6.Color = Color3.new(0, 0.560784, 0.611765)
  111. Part6.Transparency = 1
  112. Part6.Size = Vector3.new(1, 1, 1)
  113. Part6.Anchored = true
  114. Part6.BottomSurface = Enum.SurfaceType.Smooth
  115. Part6.BrickColor = BrickColor.new("Bright bluish green")
  116. Part6.FrontSurface = Enum.SurfaceType.Hinge
  117. Part6.Locked = true
  118. Part6.TopSurface = Enum.SurfaceType.Smooth
  119. Part6.brickColor = BrickColor.new("Bright bluish green")
  120. Part6.FormFactor = Enum.FormFactor.Custom
  121. Part6.formFactor = Enum.FormFactor.Custom
  122. Script7.Parent = Model3
  123. table.insert(cors,sandbox(Script7,function()
  124. local ai = {}
  125. ai.Model = script.Parent
  126.  
  127. -- The zombies memory. (You can edit these stats)
  128. local goalPos
  129. local lastAttack = time()
  130. local attackTime = .3
  131. local atkDamage = 5
  132. local goalHumanoid
  133. local running
  134. local running2
  135. local crawling
  136. local limp = {}
  137. for i = 1, 10 do
  138. limp[i] = (math.random() * 2) - 1
  139. end
  140.  
  141. -- Global functions. (I wouldnt mess with this..)
  142. ai.Move = function(loc, mustSee, humanoid)
  143. goalHumanoid = humanoid
  144. if goalPos then
  145. goalPos = loc
  146. else
  147. goalPos = loc
  148. Spawn(function()
  149. ai.State = "Tracking"
  150. local lastGoal
  151. local lastTime = time()
  152. while goalPos and ai.Humanoid do
  153. local gp = goalPos
  154. if pcall(function() return goalPos.X end) then
  155. elseif goalPos:IsA("BasePart") then
  156. gp = (ai.canSee(goalPos) or not mustSee) and goalPos.Position or nil
  157. lastTime = time()
  158. elseif goalPos:IsA("Model") then
  159. gp = nil
  160. for _, bodyPart in pairs(goalPos:GetChildren()) do
  161. if bodyPart:IsA("BasePart") and (ai.canSee(bodyPart) or not mustSee) then
  162. gp = goalPos:GetModelCFrame().p
  163. lastTime = time()
  164. break
  165. end
  166. end
  167. end
  168. lastGoal = gp and humanoid and gp + (gp - ai.Model.Torso.Position).unit * 10 or gp or lastGoal or ai.Model.Torso.Position
  169. if (goalHumanoid and goalHumanoid.Health <= 0) or (not goalHumanoid and (ai.Model.Torso.Position - lastGoal).magnitude < 3) or time() - lastTime > 3 then
  170. goalPos = nil
  171. else
  172. ai.Humanoid.Jump = objAhead(lastGoal)
  173. ai.Humanoid:MoveTo(lastGoal, workspace.Terrain)
  174. if goalHumanoid and ((ai.Model.Torso.Position - goalPos:GetModelCFrame().p) * Vector3.new(1,.5,1)).magnitude < 3 and time() - lastAttack > attackTime then
  175. attack(goalHumanoid)
  176. end
  177. end
  178. wait(.1)
  179. end
  180. if ai then
  181. ai.State = "Idle"
  182. end
  183. end)
  184. end
  185. end
  186.  
  187.  
  188.  
  189.  
  190. --local functions
  191. function weld(a, b, c0, c1)
  192. local w = Instance.new("Weld", a)
  193. w.Part0 = a
  194. w.Part1 = b
  195. if c0 then w.C0 = c0 end
  196. if c1 then w.C1 = c1 end
  197. return w
  198. end
  199.  
  200. function setHeight(n)
  201. if ai.Model:findFirstChild("Right Leg") then
  202. ai.Model["Right Leg"]:BreakJoints()
  203. ai.Model["Right Leg"].Size = ai.Model["Right Leg"].Size * Vector3.new(1,0,1) + Vector3.new(0, math.max(0.2, n or 0),0)
  204. weld(ai.Model.Torso, ai.Model["Right Leg"], CFrame.new(0, -n + ai.Model["Right Leg"].Size.Y/2 - ai.Model.Torso.Size.Y/2,0))
  205. end
  206. if m and ai.Model:findFirstChild("Head") then
  207. ai.Model.Head:BreakJoints()
  208. weld(ai.Model.Torso, ai.Model.Head, CFrame.new(0, m - ai.Model.Head.Size.Y/2 + ai.Model.Torso.Size.Y/2,0))
  209. end
  210. end
  211.  
  212. function objAhead(loc)
  213. if not _G.AntiJumpCache then
  214. _G.AntiJumpCache = {}
  215. end
  216. local ray = Ray.new(ai.Model.Torso.Position, ((loc - ai.Model.Torso.Position) * Vector3.new(1,0,1)).unit * 5)
  217. local obj, pos = workspace:FindPartOnRayWithIgnoreList(ray, _G.AntiJumpCache)
  218. if obj then
  219. if not obj.CanCollide then
  220. table.insert(_G.AntiJumpCache, obj)
  221. elseif obj.Parent:findFirstChild("Humanoid") then
  222. table.insert(_G.AntiJumpCache, obj.Parent)
  223. else
  224. return true
  225. end
  226. --add to cache if necessary, otherwise recurse
  227. return objAhead(loc)
  228. end
  229. end
  230.  
  231. function ai.canSee(obj, fov)
  232. local direction = (obj.Position - ai.Model.Head.Position).unit
  233. if fov and direction:Dot(ai.Model.Head.CFrame.lookVector) < math.cos(math.rad(fov)) then
  234. return false
  235. end
  236. local ray = Ray.new(ai.Model.Head.Position, direction * 900)
  237. local hit, pos = workspace:FindPartOnRayWithIgnoreList(ray, {ai.Model})
  238. if hit then
  239. --add to cache if transparent?
  240. if hit == obj then
  241. return true
  242. end
  243. end
  244. end
  245.  
  246. function attack(hum)
  247. print("pow")
  248. lastAttack = time()
  249. hum:TakeDamage(atkDamage)
  250. end
  251.  
  252. function initialize()
  253. for _, obj in pairs(ai.Model:GetChildren()) do
  254. if obj:IsA("BasePart") then
  255. obj.Anchored = false
  256. end
  257. end
  258. setHeight(2, 1)
  259. ai.tWeld = weld(ai.Model.Torso, ai.Model.torso, CFrame.new(0,-1,0), CFrame.new(0,-1,0) * CFrame.Angles(math.rad(45),0,0))
  260. ai.hWeld = weld(ai.Model.torso, ai.Model.head2, CFrame.new(0,.8,0), CFrame.new(0,-.6,0) * CFrame.Angles(math.rad(-22.5),0,0))
  261. ai.lWeld1 = weld(ai.Model.torso, ai.Model.leftLeg, CFrame.new(-0.5,-1,0), CFrame.new(0,1,0) * CFrame.Angles(math.rad(-45),0,0))
  262. ai.lWeld2 = weld(ai.Model.torso, ai.Model.rightLeg, CFrame.new(0.5,-1,0), CFrame.new(0,1,0) * CFrame.Angles(math.rad(-45),0,0))
  263. ai.aWeld1 = weld(ai.Model.torso, ai.Model.leftArm, CFrame.new(-1,0.5,0), CFrame.new(0.5,0.5,0) * CFrame.Angles(math.rad(-45),0,0))
  264. ai.aWeld2 = weld(ai.Model.torso, ai.Model.rightArm, CFrame.new(1,0.5,0), CFrame.new(-0.5,0.5,0) * CFrame.Angles(math.rad(-45),0,0))
  265. ai.HWeld = weld(ai.Model.Torso, ai.Model.Head)
  266. anim(math.rad(20),0,0)
  267. ai.Humanoid = Instance.new("Humanoid", ai.Model)
  268. ai.Humanoid.WalkSpeed = math.random(8,14) + math.max(0, math.random(-5,3))
  269. ai.State = "Idle"
  270. ai.Model.ChildRemoved:connect(delete)
  271. ai.Humanoid.Died:connect(delete)
  272. ai.Humanoid.Running:connect(animate)
  273. table.insert(_G.aiTable, ai)
  274. end
  275.  
  276. function delete()
  277. wait(0)
  278. if not ai.Humanoid or not (ai.Humanoid.Health > 0) or not ai.Model:findFirstChild("Torso") or not ai.Model:FindFirstChild("Head") or not ai.Model:FindFirstChild("head2") then
  279. for i, a in pairs(_G.aiTable) do
  280. if a == ai then
  281. table.remove(_G.aiTable, i)
  282. end
  283. end
  284. ai.Model:BreakJoints()
  285. game.Debris:AddItem(ai.Model, 3)
  286. for i, obj in pairs(ai.Model:GetChildren()) do
  287. if obj:IsA("BasePart") and obj.Transparency ~= 1 then
  288. obj.CanCollide = true
  289. elseif obj ~= script then
  290. obj:Destroy()
  291. end
  292. end
  293. ai = nil
  294. goalPos = nil
  295. elseif not (ai.Model:FindFirstChild("leftLeg") and ai.Model:FindFirstChild("rightLeg")) and not crawling then
  296. crawl()
  297. end
  298. if ai and crawling and not (ai.Model:FindFirstChild("leftArm") and ai.Model:FindFirstChild("rightArm")) then
  299. ai.Humanoid.Health = 0
  300. end
  301. end
  302.  
  303. function animate(a)
  304. if not running2 then
  305. running = a > 0
  306. if running then
  307. Spawn(function()
  308. running2 = true
  309. local start = time()
  310. while running do
  311. wait(0)
  312. local cycle = (tick() - start) * 5
  313. local tPitch = math.rad(25 + math.cos(cycle * 2) * -5)
  314. local tRoll = math.rad(math.sin(cycle) * 10)
  315. local lPitch = math.rad(math.sin(cycle) * 45)
  316. anim(tPitch, tRoll, lPitch)
  317. end
  318. running2 = false
  319. anim(math.rad(20),0,0)
  320. end)
  321. end
  322. else
  323. running = a > 0
  324. end
  325. end
  326.  
  327. function anim(tPitch, tRoll, lPitch)
  328. if not ai then return end
  329. local crawlMod = crawling and math.rad(50) or 0
  330. local crawlMod2 = crawling and 4 or 1
  331. local attackMod = (attackTime - math.min(attackTime,(time() - lastAttack)))/attackTime * math.rad(140)
  332. lPitch2 = crawling and lPitch / 3 or lPitch
  333. if ai.tWeld then
  334. ai.tWeld.C1 = CFrame.new(0,-1,0) * CFrame.Angles(tPitch + crawlMod,0,tRoll + limp[1] * .4)
  335. end
  336. if ai.hWeld then
  337. ai.hWeld.C1 = CFrame.new(0,-0.6,0) * CFrame.Angles(-tPitch/2,0,tRoll + limp[2] * .4)
  338. end
  339. if ai.lWeld1 then
  340. ai.lWeld1.C1 = CFrame.new(0,1,0) * CFrame.Angles(lPitch2 - tPitch + crawlMod + limp[3] * .4,0,-tRoll - limp[1] * .4)
  341. end
  342. if ai.lWeld2 then
  343. ai.lWeld2.C1 = CFrame.new(0,1,0) * CFrame.Angles(-lPitch2 - tPitch + crawlMod + limp[4] * .4,0,-tRoll - limp[1] * .4)
  344. end
  345. if ai.aWeld1 then
  346. ai.aWeld1.C1 = CFrame.new(0.5,0.5,0) * CFrame.Angles(0,0, crawlMod/2) * CFrame.Angles(lPitch * math.abs(limp[5]) * -0.4 * crawlMod2 - tPitch - crawlMod - attackMod + limp[5] * .2, 0, -tRoll - limp[1] * .4)
  347. end
  348. if ai.aWeld2 then
  349. ai.aWeld2.C1 = CFrame.new(-0.5,0.5,0) * CFrame.Angles(0,0, -crawlMod/2) * CFrame.Angles(lPitch * math.abs(limp[6]) * 0.4 * crawlMod2 - tPitch - crawlMod - attackMod + limp[6] * .2, 0, -tRoll - limp[1] * .4)
  350. end
  351. if ai.HWeld and ai.Model:findFirstChild("head2") then
  352. ai.HWeld.C0 = ai.Model.Torso.CFrame:toObjectSpace(ai.Model.head2.CFrame)
  353. end
  354. end
  355.  
  356. function crawl()
  357. crawling = true
  358. setHeight(0,0)
  359. ai.Humanoid.WalkSpeed = math.random(4, 6)
  360. end
  361.  
  362. while not _G.aiTable do
  363. wait(0)
  364. end
  365. initialize()
  366. end))
  367. Part8.Name = "rightLeg"
  368. Part8.Parent = Model3
  369. Part8.CFrame = CFrame.new(-11.699996, 1.00001299, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  370. Part8.Position = Vector3.new(-11.699996, 1.00001299, -16.1000061)
  371. Part8.Color = Color3.new(1, 0, 0)
  372. Part8.Size = Vector3.new(1, 2, 0.99999994)
  373. Part8.Anchored = true
  374. Part8.BottomSurface = Enum.SurfaceType.Smooth
  375. Part8.BrickColor = BrickColor.new("Really red")
  376. Part8.CanCollide = false
  377. Part8.TopSurface = Enum.SurfaceType.Smooth
  378. Part8.brickColor = BrickColor.new("Really red")
  379. Part8.FormFactor = Enum.FormFactor.Custom
  380. Part8.formFactor = Enum.FormFactor.Custom
  381. Part9.Name = "leftLeg"
  382. Part9.Parent = Model3
  383. Part9.CFrame = CFrame.new(-12.699996, 1.00001299, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  384. Part9.Position = Vector3.new(-12.699996, 1.00001299, -16.1000061)
  385. Part9.Color = Color3.new(1, 0, 0)
  386. Part9.Size = Vector3.new(1, 2, 0.99999994)
  387. Part9.Anchored = true
  388. Part9.BottomSurface = Enum.SurfaceType.Smooth
  389. Part9.BrickColor = BrickColor.new("Really red")
  390. Part9.CanCollide = false
  391. Part9.TopSurface = Enum.SurfaceType.Smooth
  392. Part9.brickColor = BrickColor.new("Really red")
  393. Part9.FormFactor = Enum.FormFactor.Custom
  394. Part9.formFactor = Enum.FormFactor.Custom
  395. Part10.Name = "leftArm"
  396. Part10.Parent = Model3
  397. Part10.CFrame = CFrame.new(-13.7000055, 3.00001192, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  398. Part10.Position = Vector3.new(-13.7000055, 3.00001192, -16.1000061)
  399. Part10.Color = Color3.new(1, 0, 0)
  400. Part10.Size = Vector3.new(1, 2, 0.99999994)
  401. Part10.Anchored = true
  402. Part10.BottomSurface = Enum.SurfaceType.Smooth
  403. Part10.BrickColor = BrickColor.new("Really red")
  404. Part10.CanCollide = false
  405. Part10.TopSurface = Enum.SurfaceType.Smooth
  406. Part10.brickColor = BrickColor.new("Really red")
  407. Part10.FormFactor = Enum.FormFactor.Custom
  408. Part10.formFactor = Enum.FormFactor.Custom
  409. Part11.Name = "torso"
  410. Part11.Parent = Model3
  411. Part11.CFrame = CFrame.new(-12.199996, 3.00001192, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  412. Part11.Position = Vector3.new(-12.199996, 3.00001192, -16.1000061)
  413. Part11.Color = Color3.new(1, 0, 0)
  414. Part11.Size = Vector3.new(2, 2, 0.99999994)
  415. Part11.Anchored = true
  416. Part11.BottomSurface = Enum.SurfaceType.Smooth
  417. Part11.BrickColor = BrickColor.new("Really red")
  418. Part11.CanCollide = false
  419. Part11.Locked = true
  420. Part11.TopSurface = Enum.SurfaceType.Smooth
  421. Part11.brickColor = BrickColor.new("Really red")
  422. Part11.FormFactor = Enum.FormFactor.Custom
  423. Part11.formFactor = Enum.FormFactor.Custom
  424. Part12.Name = "rightArm"
  425. Part12.Parent = Model3
  426. Part12.CFrame = CFrame.new(-10.699996, 3.00001192, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  427. Part12.Position = Vector3.new(-10.699996, 3.00001192, -16.1000061)
  428. Part12.Color = Color3.new(1, 0, 0)
  429. Part12.Size = Vector3.new(1, 2, 0.99999994)
  430. Part12.Anchored = true
  431. Part12.BottomSurface = Enum.SurfaceType.Smooth
  432. Part12.BrickColor = BrickColor.new("Really red")
  433. Part12.CanCollide = false
  434. Part12.TopSurface = Enum.SurfaceType.Smooth
  435. Part12.brickColor = BrickColor.new("Really red")
  436. Part12.FormFactor = Enum.FormFactor.Custom
  437. Part12.formFactor = Enum.FormFactor.Custom
  438. Part13.Name = "head2"
  439. Part13.Parent = Model3
  440. Part13.CFrame = CFrame.new(-12.199996, 4.50000381, -16.1000061, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  441. Part13.Position = Vector3.new(-12.199996, 4.50000381, -16.1000061)
  442. Part13.Color = Color3.new(1, 0, 0)
  443. Part13.Size = Vector3.new(1, 1, 1)
  444. Part13.Anchored = true
  445. Part13.BottomSurface = Enum.SurfaceType.Smooth
  446. Part13.BrickColor = BrickColor.new("Really red")
  447. Part13.CanCollide = false
  448. Part13.TopSurface = Enum.SurfaceType.Smooth
  449. Part13.brickColor = BrickColor.new("Really red")
  450. Part13.FormFactor = Enum.FormFactor.Custom
  451. Part13.formFactor = Enum.FormFactor.Custom
  452. SpecialMesh14.Parent = Part13
  453. SpecialMesh14.Scale = Vector3.new(1.39999998, 1.39999998, 1.39999998)
  454. Decal15.Name = "Rage Face"
  455. Decal15.Parent = Part13
  456. Decal15.Texture = "http://www.roblox.com/asset/?id=109676489"
  457. Script16.Name = "Controller"
  458. Script16.Parent = Model0
  459. table.insert(cors,sandbox(Script16,function()
  460. _G.aiTable = {}
  461.  
  462. while wait(.1) do
  463. for i, ai in pairs(_G.aiTable) do
  464. if ai ~= nil and ai.State == "Idle" then
  465. local closestChar
  466. local closestDist = 200 -- Edit this value, it changes how close you have to be to the zombie for it to attack or "see" you.
  467. local pos = ai.Model:GetModelCFrame().p
  468. for j, player in pairs(game.Players:GetPlayers()) do
  469. if player.Character and player.Character:findFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 then
  470. local dist = (player.Character:GetModelCFrame().p - pos).magnitude
  471. if dist <= closestDist then
  472. for _, obj in pairs(player.Character:GetChildren()) do
  473. if obj:IsA("BasePart") and (ai.canSee(obj, 85) or ai.canSee(obj) and dist <= 10)then
  474. closestChar = player.Character
  475. closestDist = dist
  476. break
  477. end
  478. end
  479. end
  480. end
  481. end
  482. if closestChar then
  483. ai.Move(closestChar, true, closestChar:findFirstChild("Humanoid"))
  484. elseif math.random() > 0.8 then
  485. local dir = CFrame.Angles(0,math.random() * math.pi * 2,0).lookVector
  486. local _, pos = workspace:FindPartOnRay(Ray.new(ai.Model:GetModelCFrame().p, dir * math.random(10,20)), ai.Model)
  487. pos = pos - dir * 5
  488. ai.Move(pos)
  489. end
  490. end
  491. end
  492. end
  493. end))
  494. for i,v in pairs(mas:GetChildren()) do
  495. v.Parent = script
  496. pcall(function() v:MakeJoints() end)
  497. end
  498. mas:Destroy()
  499. for i,v in pairs(cors) do
  500. spawn(function()
  501. pcall(v)
  502. end)
  503. end
Advertisement
Add Comment
Please, Sign In to add comment