sawgamer1

Untitled

Apr 30th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 68.89 KB | None | 0 0
  1. --https://github.com/Mokiros/roblox-FE-compatibility
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end
  6.  
  7. --Converted with ttyyuu12345's model to script plugin v4
  8. function sandbox(var,func)
  9. local env = getfenv(func)
  10. local newenv = setmetatable({},{
  11. __index = function(self,k)
  12. if k=="script" then
  13. return var
  14. else
  15. return env[k]
  16. end
  17. end,
  18. })
  19. setfenv(func,newenv)
  20. return func
  21. end
  22. cors = {}
  23. mas = Instance.new("Model",game:GetService("Lighting"))
  24. Model0 = Instance.new("Model")
  25. Part1 = Instance.new("Part")
  26. SpecialMesh2 = Instance.new("SpecialMesh")
  27. Decal3 = Instance.new("Decal")
  28. Part4 = Instance.new("Part")
  29. Decal5 = Instance.new("Decal")
  30. Motor6 = Instance.new("Motor")
  31. Motor7 = Instance.new("Motor")
  32. Motor8 = Instance.new("Motor")
  33. Motor9 = Instance.new("Motor")
  34. Motor10 = Instance.new("Motor")
  35. Part11 = Instance.new("Part")
  36. Part12 = Instance.new("Part")
  37. Part13 = Instance.new("Part")
  38. Part14 = Instance.new("Part")
  39. Humanoid15 = Instance.new("Humanoid")
  40. CFrameValue16 = Instance.new("CFrameValue")
  41. BoolValue17 = Instance.new("BoolValue")
  42. IntValue18 = Instance.new("IntValue")
  43. BoolValue19 = Instance.new("BoolValue")
  44. BrickColorValue20 = Instance.new("BrickColorValue")
  45. BoolValue21 = Instance.new("BoolValue")
  46. BoolValue22 = Instance.new("BoolValue")
  47. BoolValue23 = Instance.new("BoolValue")
  48. Vector3Value24 = Instance.new("Vector3Value")
  49. BoolValue25 = Instance.new("BoolValue")
  50. BoolValue26 = Instance.new("BoolValue")
  51. BodyColors27 = Instance.new("BodyColors")
  52. BoolValue28 = Instance.new("BoolValue")
  53. Script29 = Instance.new("Script")
  54. IntValue30 = Instance.new("IntValue")
  55. IntValue31 = Instance.new("IntValue")
  56. IntValue32 = Instance.new("IntValue")
  57. Script33 = Instance.new("Script")
  58. ParticleEmitter34 = Instance.new("ParticleEmitter")
  59. Model0.Name = "NPC"
  60. Model0.Parent = mas
  61. Model0.PrimaryPart = Part1
  62. Part1.Name = "Head"
  63. Part1.Parent = Model0
  64. Part1.CFrame = CFrame.new(0.969980001, 4.50000095, 11.22999, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  65. Part1.Position = Vector3.new(0.969980001, 4.50000095, 11.22999)
  66. Part1.Color = Color3.new(0.960784, 0.803922, 0.188235)
  67. Part1.Size = Vector3.new(2, 1, 1)
  68. Part1.BrickColor = BrickColor.new("Bright yellow")
  69. Part1.TopSurface = Enum.SurfaceType.Smooth
  70. Part1.brickColor = BrickColor.new("Bright yellow")
  71. Part1.FormFactor = Enum.FormFactor.Symmetric
  72. Part1.formFactor = Enum.FormFactor.Symmetric
  73. SpecialMesh2.Parent = Part1
  74. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  75. Decal3.Name = "face"
  76. Decal3.Parent = Part1
  77. Decal3.Texture = "rbxasset://textures/face.png"
  78. Part4.Name = "Torso"
  79. Part4.Parent = Model0
  80. Part4.CFrame = CFrame.new(0.969980001, 3.00000095, 11.22999, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  81. Part4.Position = Vector3.new(0.969980001, 3.00000095, 11.22999)
  82. Part4.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  83. Part4.Size = Vector3.new(2, 2, 1)
  84. Part4.BrickColor = BrickColor.new("Bright blue")
  85. Part4.LeftParamA = 0
  86. Part4.LeftParamB = 0
  87. Part4.LeftSurface = Enum.SurfaceType.Weld
  88. Part4.RightParamA = 0
  89. Part4.RightParamB = 0
  90. Part4.RightSurface = Enum.SurfaceType.Weld
  91. Part4.brickColor = BrickColor.new("Bright blue")
  92. Part4.FormFactor = Enum.FormFactor.Symmetric
  93. Part4.formFactor = Enum.FormFactor.Symmetric
  94. Decal5.Name = "roblox"
  95. Decal5.Parent = Part4
  96. Motor6.Name = "Right Shoulder"
  97. Motor6.Parent = Part4
  98. Motor6.MaxVelocity = 0.15000000596046
  99. Motor6.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  100. Motor6.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  101. Motor6.Part0 = Part4
  102. Motor6.Part1 = Part12
  103. Motor6.part1 = Part12
  104. Motor7.Name = "Left Shoulder"
  105. Motor7.Parent = Part4
  106. Motor7.MaxVelocity = 0.15000000596046
  107. Motor7.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  108. Motor7.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  109. Motor7.Part0 = Part4
  110. Motor7.Part1 = Part11
  111. Motor7.part1 = Part11
  112. Motor8.Name = "Right Hip"
  113. Motor8.Parent = Part4
  114. Motor8.MaxVelocity = 0.10000000149012
  115. Motor8.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  116. Motor8.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  117. Motor8.Part0 = Part4
  118. Motor8.Part1 = Part14
  119. Motor8.part1 = Part14
  120. Motor9.Name = "Left Hip"
  121. Motor9.Parent = Part4
  122. Motor9.MaxVelocity = 0.10000000149012
  123. Motor9.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  124. Motor9.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  125. Motor9.Part0 = Part4
  126. Motor9.Part1 = Part13
  127. Motor9.part1 = Part13
  128. Motor10.Name = "Neck"
  129. Motor10.Parent = Part4
  130. Motor10.MaxVelocity = 0.10000000149012
  131. Motor10.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  132. Motor10.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  133. Motor10.Part0 = Part4
  134. Motor10.Part1 = Part1
  135. Motor10.part1 = Part1
  136. Part11.Name = "Left Arm"
  137. Part11.Parent = Model0
  138. Part11.CFrame = CFrame.new(-0.530019999, 3.00000095, 11.22999, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  139. Part11.Position = Vector3.new(-0.530019999, 3.00000095, 11.22999)
  140. Part11.Color = Color3.new(0.960784, 0.803922, 0.188235)
  141. Part11.Size = Vector3.new(1, 2, 1)
  142. Part11.BrickColor = BrickColor.new("Bright yellow")
  143. Part11.CanCollide = false
  144. Part11.brickColor = BrickColor.new("Bright yellow")
  145. Part11.FormFactor = Enum.FormFactor.Symmetric
  146. Part11.formFactor = Enum.FormFactor.Symmetric
  147. Part12.Name = "Right Arm"
  148. Part12.Parent = Model0
  149. Part12.CFrame = CFrame.new(2.46998, 3.00000095, 11.22999, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  150. Part12.Position = Vector3.new(2.46998, 3.00000095, 11.22999)
  151. Part12.Color = Color3.new(0.960784, 0.803922, 0.188235)
  152. Part12.Size = Vector3.new(1, 2, 1)
  153. Part12.BrickColor = BrickColor.new("Bright yellow")
  154. Part12.CanCollide = false
  155. Part12.brickColor = BrickColor.new("Bright yellow")
  156. Part12.FormFactor = Enum.FormFactor.Symmetric
  157. Part12.formFactor = Enum.FormFactor.Symmetric
  158. Part13.Name = "Left Leg"
  159. Part13.Parent = Model0
  160. Part13.CFrame = CFrame.new(0.469980001, 1.00000095, 11.22999, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  161. Part13.Position = Vector3.new(0.469980001, 1.00000095, 11.22999)
  162. Part13.Color = Color3.new(0.643137, 0.741176, 0.278431)
  163. Part13.Size = Vector3.new(1, 2, 1)
  164. Part13.BottomSurface = Enum.SurfaceType.Smooth
  165. Part13.BrickColor = BrickColor.new("Br. yellowish green")
  166. Part13.CanCollide = false
  167. Part13.TopSurface = Enum.SurfaceType.Inlet
  168. Part13.brickColor = BrickColor.new("Br. yellowish green")
  169. Part13.FormFactor = Enum.FormFactor.Symmetric
  170. Part13.formFactor = Enum.FormFactor.Symmetric
  171. Part14.Name = "Right Leg"
  172. Part14.Parent = Model0
  173. Part14.CFrame = CFrame.new(1.46998, 1.00000095, 11.22999, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  174. Part14.Position = Vector3.new(1.46998, 1.00000095, 11.22999)
  175. Part14.Color = Color3.new(0.643137, 0.741176, 0.278431)
  176. Part14.Size = Vector3.new(1, 2, 1)
  177. Part14.BottomSurface = Enum.SurfaceType.Smooth
  178. Part14.BrickColor = BrickColor.new("Br. yellowish green")
  179. Part14.CanCollide = false
  180. Part14.TopSurface = Enum.SurfaceType.Inlet
  181. Part14.brickColor = BrickColor.new("Br. yellowish green")
  182. Part14.FormFactor = Enum.FormFactor.Symmetric
  183. Part14.formFactor = Enum.FormFactor.Symmetric
  184. Humanoid15.Parent = Model0
  185. Humanoid15.LeftLeg = Part13
  186. Humanoid15.NameOcclusion = Enum.NameOcclusion.NoOcclusion
  187. Humanoid15.RightLeg = Part14
  188. Humanoid15.Torso = Part4
  189. CFrameValue16.Name = "IsAPlayer"
  190. CFrameValue16.Parent = Model0
  191. BoolValue17.Name = "Respawn"
  192. BoolValue17.Parent = Model0
  193. BoolValue17.Value = true
  194. IntValue18.Name = "Force_Weapon"
  195. IntValue18.Parent = Model0
  196. BoolValue19.Name = "IsOnTeam"
  197. BoolValue19.Parent = Model0
  198. BrickColorValue20.Name = "Team"
  199. BrickColorValue20.Parent = BoolValue19
  200. BrickColorValue20.Value = BrickColor.new("Really black")
  201. BoolValue21.Name = "ShowTag"
  202. BoolValue21.Parent = BoolValue19
  203. BoolValue22.Name = "IgnoreCombatFF"
  204. BoolValue22.Parent = Model0
  205. BoolValue22.Value = true
  206. BoolValue23.Name = "DropWeapon"
  207. BoolValue23.Parent = Model0
  208. BoolValue23.Value = true
  209. Vector3Value24.Name = "PathTo"
  210. Vector3Value24.Parent = Model0
  211. BoolValue25.Name = "Wander"
  212. BoolValue25.Parent = Model0
  213. BoolValue25.Value = true
  214. BoolValue26.Name = "PrintMap"
  215. BoolValue26.Parent = Model0
  216. BodyColors27.Parent = Model0
  217. BodyColors27.HeadColor = BrickColor.new("Bright yellow")
  218. BodyColors27.HeadColor3 = Color3.new(0.960784, 0.803922, 0.188235)
  219. BodyColors27.LeftArmColor = BrickColor.new("Bright yellow")
  220. BodyColors27.LeftArmColor3 = Color3.new(0.960784, 0.803922, 0.188235)
  221. BodyColors27.LeftLegColor = BrickColor.new("Br. yellowish green")
  222. BodyColors27.LeftLegColor3 = Color3.new(0.643137, 0.741176, 0.278431)
  223. BodyColors27.RightArmColor = BrickColor.new("Bright yellow")
  224. BodyColors27.RightArmColor3 = Color3.new(0.960784, 0.803922, 0.188235)
  225. BodyColors27.RightLegColor = BrickColor.new("Br. yellowish green")
  226. BodyColors27.RightLegColor3 = Color3.new(0.643137, 0.741176, 0.278431)
  227. BodyColors27.TorsoColor = BrickColor.new("Bright blue")
  228. BodyColors27.TorsoColor3 = Color3.new(0.0509804, 0.411765, 0.67451)
  229. BoolValue28.Name = "ForceColors"
  230. BoolValue28.Parent = BodyColors27
  231. Script29.Name = "Full Animation"
  232. Script29.Parent = Model0
  233. table.insert(cors,sandbox(Script29,function()
  234. --[[Made by Jammer622 @[http://www.roblox.com/Advanced-Player-AI-item?id=59391730],
  235. This is the ORIGINAL model, if you see others, they are stolen.
  236. Scripts mixed from vanilla Animate, Health, and Sound,
  237. with much custom content by myself, making them great AIs.
  238. No help from Miked's scripts, I made my own joint script.
  239. If you find any glitches, bugs, or just want to suggest an idea, please message me.
  240. My team works hard on these AIs, please don't make attempts to steal them.
  241. Your feedback is extremely appreciated!
  242.  
  243. _---=CREDITS=---_
  244. The Roblox Team Without them, none of this would be possible.
  245. Vanilla Sound
  246. Vanilla Health
  247. Vanilla Animate
  248. Jammer622 That's me, main programmer and weapon publisher.
  249. Main Developer
  250. Health GUI Script
  251. Animation Work
  252. Relationship Work
  253. Wandering
  254. Pathing (Map Generation)
  255. Weapon Usage
  256. Weapon (Re)Publishing
  257. Sonypony458
  258. McDonalds Drink
  259. Customization
  260. Teamwork AI
  261. Model Variables
  262. Setting Wiki [Below]
  263. Macdeath I owe it to him for keeping me on track during this.
  264. Feature Inspiration
  265. Problem Solving
  266. Suggestions
  267. lah30303 Amazing pathing work goes to this fine sir.
  268. Pathing (Pathing Generation/System)
  269.  
  270. _---=SETTINGS=---_
  271. Inside this model's file, you'll find several values that can be changed.
  272. DropWeapon -This sets whether or not the bot will drop any equipped weapon upon dying.
  273. Force_Pants -This must be set through Spawners.
  274. Force_Shirt -This must be set through Spawners.
  275. Force_Weapon -This must be set through Spawners.
  276. Force_Hat -This must be set through Spawners.
  277. IgnoreCombatFF -This sets whether or not the bot will allow friendly fire during combat.
  278. IsAPlayer -This is a tag to specify this bot's existance to other AIs.
  279. IsOnTeam -This sets whether or not the bot is on a team.
  280. ShowTag -This sets whether or not the bot's team color name shows up beside its own.
  281. Team -This sets the bot's team color.
  282. PathTo -This is an experimental pathfinding engine. Use at your own risk!
  283. PrintMap -This prints maps generated when using PathTo. Use at your own risk!
  284. Respawn -This sets whether the bot will respawn or not upon death.
  285. Custom_Name -This must be set through Spawners.
  286. Wander -This sets whether the bot is stationary or if it moves, but not if it uses weapons or not.
  287. ]]
  288. print("Player Bot Loading")
  289. Delay(0, function() --Vanilla Sound
  290. function waitForChild(parent, childName)
  291. local child = parent:findFirstChild(childName)
  292. if child then return child end
  293. while true do
  294. child = parent.ChildAdded:wait()
  295. if child.Name==childName then return child end
  296. end
  297. end
  298. function newSound(id)
  299. local sound = Instance.new("Sound")
  300. sound.SoundId = id
  301. sound.archivable = false
  302. sound.Parent = script.Parent.Head
  303. return sound
  304. end
  305. local sDied = newSound("rbxasset://sounds/uuhhh.wav")
  306. local sFallingDown = newSound("rbxasset://sounds/splat.wav")
  307. local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
  308. local sGettingUp = newSound("rbxasset://sounds/hit.wav")
  309. local sJumping = newSound("rbxasset://sounds/button.wav")
  310. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
  311. sRunning.Looped = true
  312. local Figure = script.Parent
  313. local Head = waitForChild(Figure, "Head")
  314. local Humanoid = waitForChild(Figure, "Humanoid")
  315. function onDied()
  316. sDied:Play()
  317. end
  318. function onState(state, sound)
  319. if state then
  320. sound:Play()
  321. else
  322. sound:Pause()
  323. end
  324. end
  325. function onRunning(speed)
  326. if speed>0 then
  327. sRunning:Play()
  328. else
  329. sRunning:Pause()
  330. end
  331. end
  332. Humanoid.Died:connect(onDied)
  333. Humanoid.Running:connect(onRunning)
  334. Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
  335. Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
  336. Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
  337. Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
  338. end)
  339. Delay(0, function() --Vanilla Health
  340. function waitForChild(parent, childName)
  341. local child = parent:findFirstChild(childName)
  342. if child then return child end
  343. while true do
  344. child = parent.ChildAdded:wait()
  345. if child.Name==childName then return child end
  346. end
  347. end
  348. local Figure = script.Parent
  349. local Humanoid = waitForChild(Figure, "Humanoid")
  350. local regening = false
  351. function regenHealth()
  352. if regening then return end
  353. regening = true
  354. while Humanoid.Health < Humanoid.MaxHealth do
  355. local s = wait(1)
  356. local health = Humanoid.Health
  357. if health > 0 and health < Humanoid.MaxHealth then
  358. local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
  359. health = health + newHealthDelta
  360. Humanoid.Health = math.min(health,Humanoid.MaxHealth)
  361. end
  362. end
  363. if Humanoid.Health > Humanoid.MaxHealth then
  364. Humanoid.Health = Humanoid.MaxHealth
  365. end
  366. regening = false
  367. end
  368. Humanoid.HealthChanged:connect(regenHealth)
  369. end)
  370. Delay(0, function() --Vanilla Animate, Multiple Additions
  371. function waitForChild(parent, childName)
  372. local child = parent:findFirstChild(childName)
  373. if child then return child end
  374. while true do
  375. child = parent.ChildAdded:wait()
  376. if child.Name==childName then return child end
  377. end
  378. end
  379. local Figure = script.Parent
  380. local Clone = Figure:Clone()
  381. local Torso = waitForChild(Figure, "Torso")
  382. local Joints = Torso:GetChildren()
  383. for All = 1, #Joints do
  384. if Joints.className == "Motor" or Joints.className == "Motor6D" then
  385. Joints[All]:Remove()
  386. end
  387. end
  388. local RightShoulder = Instance.new("Motor")
  389. local LeftShoulder = Instance.new("Motor")
  390. local RightHip = Instance.new("Motor")
  391. local LeftHip = Instance.new("Motor")
  392. local Neck = Instance.new("Motor")
  393. local Humanoid = waitForChild(Figure, "Humanoid")
  394. ZStat = 1
  395. ZStat2 = 0
  396. local pose = "Standing"
  397. RightShoulder.Part0 = Torso
  398. RightShoulder.Part1 = Figure["Right Arm"]
  399. RightShoulder.MaxVelocity = 0.15
  400. RightShoulder.Name = "Right Shoulder"
  401. RightShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  402. RightShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  403. RightShoulder.Parent = Torso
  404. LeftShoulder.Part0 = Torso
  405. LeftShoulder.Part1 = Figure["Left Arm"]
  406. LeftShoulder.MaxVelocity = 0.15
  407. LeftShoulder.Name = "Left Shoulder"
  408. LeftShoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  409. LeftShoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  410. LeftShoulder.Parent = Torso
  411. RightHip.Part0 = Torso
  412. RightHip.Part1 = Figure["Right Leg"]
  413. RightHip.MaxVelocity = 0.1
  414. RightHip.Name = "Right Hip"
  415. RightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  416. RightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  417. RightHip.Parent = Torso
  418. LeftHip.Part0 = Torso
  419. LeftHip.Part1 = Figure["Left Leg"]
  420. LeftHip.MaxVelocity = 0.1
  421. LeftHip.Name = "Left Hip"
  422. LeftHip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  423. LeftHip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  424. LeftHip.Parent = Torso
  425. Neck.Part0 = Torso
  426. Neck.Part1 = Figure["Head"]
  427. Neck.MaxVelocity = 0.1
  428. Neck.Name = "Neck"
  429. Neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  430. Neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  431. Neck.Parent = Torso
  432. local toolAnim = "None"
  433. local toolAnimTime = 0
  434. SpawnModel = Instance.new("Model")
  435. function onRunning(speed)
  436. if speed>0 then
  437. pose = "Running"
  438. else
  439. pose = "Standing"
  440. end
  441. end
  442. function CheckTag(Tag)
  443. if script.Parent:FindFirstChild("IsLocalEnemy") == nil and script.Parent:FindFirstChild("IsAZombie") == nil and Tag.ClassName == "ObjectValue" and Tag.Value ~= nil and Tag.Value.ClassName == "Player" and Tag.Value.Character ~= nil then
  444. if Tag.Value.Character:FindFirstChild("IsLocalEnemy") == nil then
  445. if (script.Parent.IsOnTeam.Value == true and IsInCombat == false and script.Parent.IsOnTeam.Team.Value == Tag.Value.TeamColor) or script.Parent.IsOnTeam.Value == false then
  446. local Tag2 = Instance.new("CFrameValue", Tag.Value.Character)
  447. Tag2.Name = "IsLocalEnemy"
  448. print(Tag.Value.Character.Name .." Has Become An Outlaw")
  449. end
  450. end
  451. if Tag.Value.Character:FindFirstChild("Loc" ..script.Parent.Name) ~= nil then
  452. Tag.Value.Character:FindFirstChild("Loc" ..script.Parent.Name):Remove()
  453. end
  454. local Found = Instance.new("CFrameValue", Tag.Value.Character)
  455. Found.Name = "Loc" ..script.Parent.Name
  456. game:GetService("Debris"):AddItem(Found, 3)
  457. elseif script.Parent:FindFirstChild("IsLocalEnemy") == nil and script.Parent:FindFirstChild("IsAZombie") == nil and Tag.ClassName == "StringValue" and game.Players:FindFirstChild(Tag.Value) ~= nil and game.Players[Tag.Value].Character ~= nil then
  458. if game.Players[Tag.Value].Character:FindFirstChild("IsLocalEnemy") == nil then
  459. if (script.Parent.IsOnTeam.Value == true and IsInCombat == false and script.Parent.IsOnTeam.Team.Value == game.Players[Tag.Value].TeamColor) or script.Parent.IsOnTeam.Value == false then
  460. local Tag2 = Instance.new("CFrameValue", game.Players[Tag.Value].Character)
  461. Tag2.Name = "IsLocalEnemy"
  462. print(Tag.Value .." Has Become An Outlaw")
  463. end
  464. end
  465. if game.Players[Tag.Value].Character:FindFirstChild("Loc" ..script.Parent.Name) ~= nil then
  466. game.Players[Tag.Value].Character:FindFirstChild("Loc" ..script.Parent.Name):Remove()
  467. end
  468. local Found = Instance.new("CFrameValue", game.Players[Tag.Value].Character)
  469. Found.Name = "Loc" ..script.Parent.Name
  470. game:GetService("Debris"):AddItem(Found, 3)
  471. elseif script.Parent:FindFirstChild("IsLocalEnemy") == nil and script.Parent:FindFirstChild("IsAZombie") == nil and Tag.ClassName == "StringValue" and game.Workspace:FindFirstChild(Tag.Value) ~= nil then
  472. if game.Workspace[Tag.Value]:FindFirstChild("IsLocalEnemy") == nil then
  473. if (script.Parent.IsOnTeam.Value == true and IsInCombat == false and Workspace[Tag.Value].IsOnTeam.Value == true and script.Parent.IsOnTeam.Team.Value == Workspace[Tag.Value].IsOnTeam.Team.Value) or script.Parent.IsOnTeam.Value == false or Workspace[Tag.Value].IsOnTeam.Value == false then
  474. local Tag2 = Instance.new("CFrameValue", game.Workspace[Tag.Value])
  475. Tag2.Name = "IsLocalEnemy"
  476. print(Tag.Value .." Has Become An Outlaw")
  477. end
  478. end
  479. if game.Workspace[Tag.Value]:FindFirstChild("Loc" ..script.Parent.Name) ~= nil then
  480. game.Workspace[Tag.Value]:FindFirstChild("Loc" ..script.Parent.Name):Remove()
  481. end
  482. local Found = Instance.new("CFrameValue", game.Workspace[Tag.Value])
  483. Found.Name = "Loc" ..script.Parent.Name
  484. game:GetService("Debris"):AddItem(Found, 3)
  485. elseif (script.Parent:FindFirstChild("IsLocalEnemy") ~= nil or script.Parent:FindFirstChild("IsAZombie") ~= nil) and Tag.ClassName == "ObjectValue" and Tag.Value ~= nil and Tag.Value.ClassName == "Player" and Tag.Value.Character ~= nil then
  486. local Found = Instance.new("CFrameValue", Tag.Value.Character)
  487. Found.Name = "Loc" ..script.Parent.Name
  488. game:GetService("Debris"):AddItem(Found, 3)
  489. elseif (script.Parent:FindFirstChild("IsLocalEnemy") ~= nil or script.Parent:FindFirstChild("IsAZombie") ~= nil) and Tag.ClassName == "StringValue" and game.Workspace:FindFirstChild(Tag.Value) ~= nil then
  490. local Found = Instance.new("CFrameValue", game.Workspace[Tag.Value])
  491. Found.Name = "Loc" ..script.Parent.Name
  492. game:GetService("Debris"):AddItem(Found, 3)
  493. end
  494. end
  495. function CheckSpawns(Object)
  496. local Parts = Object:GetChildren()
  497. for Check = 1, #Parts do
  498. if Parts[Check].className == "SpawnLocation" then
  499. local I = Instance.new("Vector3Value", SpawnModel)
  500. I.Value = Parts[Check].Position
  501. end
  502. CheckSpawns(Parts[Check])
  503. end
  504. end
  505. function onDied()
  506. pose = "Dead"
  507. Delay(5, function()
  508. if script.Parent.Respawn.Value == true then
  509. CheckSpawns(Workspace)
  510. local Spawn = SpawnModel:GetChildren()
  511. Clone.Parent = game.Workspace
  512. if #Spawn > 0 then
  513. Spawn = Spawn[math.random(1, #Spawn)].Value
  514. Clone:MoveTo(Spawn)
  515. else
  516. Clone:MoveTo(Vector3.new(0, 50, 0))
  517. end
  518. end
  519. Figure:Remove()
  520. return
  521. end)
  522. end
  523. function onJumping()
  524. pose = "Jumping"
  525. end
  526. function onClimbing()
  527. pose = "Climbing"
  528. end
  529. function onGettingUp()
  530. pose = "GettingUp"
  531. end
  532. function onFreeFall()
  533. pose = "FreeFall"
  534. end
  535. function onFallingDown()
  536. pose = "FallingDown"
  537. end
  538. function onSeated()
  539. pose = "Seated"
  540. end
  541. function onPlatformStanding()
  542. pose = "PlatformStanding"
  543. end
  544. function moveJump()
  545. RightShoulder.MaxVelocity = 0.5
  546. LeftShoulder.MaxVelocity = 0.5
  547. RightShoulder.DesiredAngle = (3.14/ZStat)
  548. LeftShoulder.DesiredAngle = (-3.14/ZStat)
  549. RightHip.DesiredAngle = (0)
  550. LeftHip.DesiredAngle = (0)
  551. end
  552. function moveFreeFall()
  553. RightShoulder.MaxVelocity = 0.5
  554. LeftShoulder.MaxVelocity = 0.5
  555. RightShoulder.DesiredAngle = (3.14/ZStat)
  556. LeftShoulder.DesiredAngle = (-3.14/ZStat)
  557. RightHip.DesiredAngle = (0)
  558. LeftHip.DesiredAngle = (0)
  559. end
  560. function moveSit()
  561. RightShoulder.MaxVelocity = 0.15
  562. LeftShoulder.MaxVelocity = 0.15
  563. RightShoulder.DesiredAngle = (3.14 /2)
  564. LeftShoulder.DesiredAngle = (-3.14 /2)
  565. RightHip.DesiredAngle = (3.14 /2)
  566. LeftHip.DesiredAngle = (-3.14 /2)
  567. end
  568. function getTool()
  569. for _, kid in ipairs(Figure:GetChildren()) do
  570. if kid.className == "Tool" then return kid end
  571. end
  572. return nil
  573. end
  574. function getToolAnim(tool)
  575. for _, c in ipairs(tool:GetChildren()) do
  576. if c.Name == "toolanim" and c.className == "StringValue" then
  577. return c
  578. end
  579. end
  580. return nil
  581. end
  582. function animateTool()
  583. if (toolAnim == "None") then
  584. RightShoulder.DesiredAngle = (1.57)
  585. return
  586. end
  587. if (toolAnim == "Slash") then
  588. RightShoulder.MaxVelocity = 0.5
  589. RightShoulder.DesiredAngle = (0)
  590. return
  591. end
  592. if (toolAnim == "Lunge") then
  593. RightShoulder.MaxVelocity = 0.5
  594. LeftShoulder.MaxVelocity = 0.5
  595. RightHip.MaxVelocity = 0.5
  596. LeftHip.MaxVelocity = 0.5
  597. RightShoulder.DesiredAngle = (1.57)
  598. LeftShoulder.DesiredAngle = (1.0)
  599. RightHip.DesiredAngle = (1.57)
  600. LeftHip.DesiredAngle = (1.0)
  601. return
  602. end
  603. end
  604. function move(time)
  605. local amplitude
  606. local frequency
  607. if (pose == "Jumping") then
  608. moveJump()
  609. return
  610. end
  611. if (pose == "FreeFall") then
  612. moveFreeFall()
  613. return
  614. end
  615. if (pose == "Seated") then
  616. moveSit()
  617. return
  618. end
  619. local climbFudge = 0
  620. if (pose == "Running") then
  621. RightShoulder.MaxVelocity = 0.15
  622. LeftShoulder.MaxVelocity = 0.15
  623. amplitude = 1
  624. frequency = 9
  625. elseif (pose == "Climbing") then
  626. RightShoulder.MaxVelocity = 0.5
  627. LeftShoulder.MaxVelocity = 0.5
  628. amplitude = 1
  629. frequency = 9
  630. climbFudge = 3.14
  631. else
  632. amplitude = 0.1
  633. frequency = 1
  634. end
  635. desiredAngle = amplitude * math.sin(time*frequency)
  636. RightShoulder.DesiredAngle = (desiredAngle + climbFudge) + ZStat2
  637. LeftShoulder.DesiredAngle = (desiredAngle - climbFudge) -ZStat2
  638. RightHip.DesiredAngle = (-desiredAngle)
  639. LeftHip.DesiredAngle = (-desiredAngle)
  640. local tool = getTool()
  641. if tool then
  642. animStringValueObject = getToolAnim(tool)
  643. if animStringValueObject then
  644. toolAnim = animStringValueObject.Value
  645. animStringValueObject.Parent = nil
  646. toolAnimTime = time + .3
  647. end
  648. if time > toolAnimTime then
  649. toolAnimTime = 0
  650. toolAnim = "None"
  651. end
  652. animateTool()
  653. else
  654. toolAnim = "None"
  655. toolAnimTime = 0
  656. end
  657. end
  658. Humanoid.Died:connect(onDied)
  659. Humanoid.Running:connect(onRunning)
  660. Humanoid.Jumping:connect(onJumping)
  661. Humanoid.Climbing:connect(onClimbing)
  662. Humanoid.GettingUp:connect(onGettingUp)
  663. Humanoid.FreeFalling:connect(onFreeFall)
  664. Humanoid.FallingDown:connect(onFallingDown)
  665. Humanoid.Seated:connect(onSeated)
  666. Humanoid.PlatformStanding:connect(onPlatformStanding)
  667. Humanoid.ChildAdded:connect(CheckTag)
  668. OriginalTime = 0.1
  669. Time = OriginalTime
  670. while Figure.Parent~=nil do
  671. Time = Time + 0.1
  672. wait(OriginalTime)
  673. move(Time)
  674. end
  675. end)
  676. Delay(0, function() --lah30303's Pathing Script
  677. function CalcMoves(map, px, py, tx, ty)
  678. if map[ty][tx] ~= 0 then
  679. return nil
  680. end
  681. local openlist, closedlist, listk, closedk, tempH, tempG, xsize, ysize, curbase = {}, {}, 1, 0, math.abs(px - tx) + math.abs(py - ty), 0, #map[1], #map, {}
  682. openlist[1] = {x = px, y = py, g = 0, h = tempH, f = 0 + tempH ,par = 1}
  683. local nodenumber = 0
  684. while listk > 0 do
  685. nodenumber = nodenumber + 1
  686. if nodenumber / ScanSkip == math.floor(nodenumber / ScanSkip) then
  687. wait()
  688. if DebugPathing == true then
  689. print("Node", nodenumber)
  690. end
  691. end
  692. closedk = closedk + 1
  693. table.insert(closedlist, closedk, openlist[1])
  694. curbase = closedlist[closedk]
  695. if closedlist[closedk].x == tx and closedlist[closedk].y == ty then
  696. return closedlist
  697. end
  698. openlist[1] = openlist[listk]
  699. table.remove(openlist, listk)
  700. listk = listk - 1
  701. local v = 1
  702. while true do
  703. local u = v
  704. if 2 * u + 1 <= listk then
  705. if openlist[u].f >= openlist[2 * u].f then
  706. v = 2 * u
  707. end
  708. if openlist[v].f >= openlist[2 * u + 1].f then
  709. v = 2 * u + 1
  710. end
  711. elseif 2 * u <= listk then
  712. if openlist[u].f >= openlist[2 * u].f then
  713. v = 2 * u
  714. end
  715. end
  716. if u ~= v then
  717. local temp = openlist[u]
  718. openlist[u] = openlist[v]
  719. openlist[v] = temp
  720. else
  721. break
  722. end
  723. end
  724.  
  725. local tocheck = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}} --[1]Right, [2]Left, [3]Down, [4]Up, [5]UpLeft, [6]UpRight, [7]DownLeft, [8]DownRight
  726. if closedk > 0 then
  727. for k = 1, closedk do
  728. for i, v in pairs(tocheck) do
  729. if closedlist[k].x == curbase.x + v[1] and closedlist[k].y == curbase.y + v[2] then
  730. tocheck[i] = nil
  731. end
  732. end
  733. end
  734. end
  735. for i, v in pairs(tocheck) do
  736. local a = curbase.x + v[1]
  737. local b = curbase.y + v[2]
  738. if a > xsize or a < 1 or b > ysize or b < 1 then
  739. tocheck[i] = nil
  740. end
  741. end
  742. for i, v in pairs(tocheck) do
  743. local a, b = curbase.x + v[1], curbase.y + v[2]
  744. if a <= xsize and a >= 1 and b <= ysize and b >= 1 and map[b][a] ~= 0 then
  745. tocheck[i] = nil
  746. end
  747. end
  748. tempG = curbase.g + 1
  749. tempDiagG = curbase.g + 1.4
  750. for k = 1, listk do
  751. for i, v in pairs(tocheck) do
  752. if openlist[k].x == curbase.x + v[1] and openlist[k].y == curbase.y + 1 and openlist[k].g > tempG then
  753. tempH = math.abs((curbase.x + v[1])-tx) + math.abs((curbase.y + v[1])-ty)
  754. table.insert(openlist, k, {x = curbase.x + v[1], y = curbase.y + v[2], g = tempG, h = tempH, f = tempG + tempH, par = closedk})
  755. local m = k
  756. while m ~= 1 do
  757. if openlist[m].f <= openlist[math.floor(m/2)].f then
  758. temp = openlist[math.floor(m/2)]
  759. openlist[math.floor(m/2)] = openlist[m]
  760. openlist[m] = temp
  761. m = math.floor(m/2)
  762. else
  763. break
  764. end
  765. tocheck[i] = nil
  766. end
  767. end
  768. end
  769. end
  770. for i, v in pairs(tocheck) do
  771. listk = listk + 1
  772. tempH = math.abs((curbase.x + v[1]) - tx) + math.abs((curbase.y + v[2]) - ty)
  773. table.insert(openlist, listk, {x = curbase.x + v[1], y = curbase.y + v[2], g = tempG, h = tempH, f = tempG+tempH, par = closedk})
  774. m = listk
  775. while m ~= 1 do
  776. if openlist[m].f <= openlist[math.floor(m/2)].f then
  777. temp = openlist[math.floor(m/2)]
  778. openlist[math.floor(m/2)] = openlist[m]
  779. openlist[m] = temp
  780. m = math.floor(m/2)
  781. else
  782. break
  783. end
  784. end
  785. end
  786. end
  787. return nil
  788. end
  789.  
  790.  
  791. function CalcPath(closedlist)
  792.  
  793. if closedlist == nil or table.getn(closedlist) == 1 then
  794. return nil
  795. end
  796. local path = {}
  797. local pathIndex = {}
  798. local last = table.getn(closedlist)
  799. table.insert(pathIndex,1,last)
  800.  
  801. local i = 1
  802. while pathIndex[i] > 1 do
  803. i = i + 1
  804. table.insert(pathIndex, i, closedlist[pathIndex[i - 1]].par)
  805. end
  806.  
  807. for n = table.getn(pathIndex) - 1, 1, -1 do
  808. table.insert(path, {x = closedlist[pathIndex[n]].x, y = closedlist[pathIndex[n]].y})
  809. end
  810.  
  811. closedlist = nil
  812. return path
  813. end
  814. end)
  815. Delay(0, function() --Main Artificial Intelligence Scripting/Path Grid Generator
  816. local Base
  817. if script.Parent:FindFirstChild("BASE") == nil then
  818. Base = Instance.new("Part")
  819. Base.Transparency = 1
  820. Base.TopSurface = "Smooth"
  821. Base.BottomSurface = "Smooth"
  822. Base.CanCollide = false
  823. Base.Anchored = true
  824. Base.Locked = true
  825. Base.BrickColor = BrickColor.new(0, 0, 0)
  826. Base.Name = "BASE"
  827. Base.CFrame = CFrame.new(Vector3.new(0, 0, 0))
  828. Base.Parent = script.Parent
  829. else
  830. Base = script.Parent.BASE
  831. Base.CFrame = CFrame.new(Vector3.new(0, 0, 0))
  832. end
  833. function Jump()
  834. script.Parent.Humanoid.Jump = true
  835. end
  836. function Check(Hit)
  837. if Hit ~= nil and Hit.Parent ~= nil and Hit.Parent.Parent ~= nil then
  838. if Hit.Parent:FindFirstChild("Humanoid") == nil and Hit.Parent.Parent:FindFirstChild("Humanoid") == nil then
  839. Jump()
  840. end
  841. end
  842. end
  843. script.Parent.Torso.Touched:connect(Check)
  844. function Prep(Target, Current, Attempts)
  845. if Attempts == nil then
  846. Attempts = 1000
  847. end
  848. local Hit = false
  849. local Tag = Base:Clone()
  850. Tag.Position = Target
  851. Tag.Parent = script.Parent
  852. local TagRay = Ray.new(Tag.CFrame.p, (CFrame.new(Tag.CFrame.p - Vector3.new(0, 3, 0)).p - Tag.CFrame.p).Unit * 40)
  853. local TRHit, TRPos = game.Workspace:FindPartOnRay(TagRay, script.Parent)
  854. if TRHit ~= nil then
  855. Hit = true
  856. end
  857. if Tag.Parent ~= nil then
  858. Tag:Remove()
  859. end
  860. if Hit == false and Attempts > 0 and script.Parent.Wander.Value == true then
  861. Prep(script.Parent.Torso.Position + Vector3.new(math.random(-100, 100), 0, math.random(-100, 100)), Base, Attempts - 1)
  862. elseif script.Parent.Wander.Value == true then
  863. local TargetRay = Ray.new(script.Parent.Torso.CFrame.p, (CFrame.new(Target).p - script.Parent.Torso.CFrame.p).Unit * ((Target - script.Parent.Torso.Position).Magnitude - 3))
  864. local THit, TPos = game.Workspace:FindPartOnRay(TargetRay, script.Parent)
  865. local TrueTarget = script.Parent.Torso.Position
  866. if THit ~= nil then
  867. for HazardCheck = 1, math.floor((script.Parent.Torso.CFrame.p - TPos).Magnitude) do
  868. local TR2 = Ray.new(script.Parent.Torso.CFrame.p + (TPos - script.Parent.Torso.CFrame.p).Unit * HazardCheck, Vector3.new(0, -50, 0) + (TPos - script.Parent.Torso.CFrame.p).Unit * 3)
  869. local TH2, TP2 = game.Workspace:FindPartOnRay(TR2, script.Parent)
  870. if TH2 ~= nil and TH2.Name ~= "Lava" then
  871. TrueTarget = TP2
  872. else
  873. break
  874. end
  875. end
  876. else
  877. for HazardCheck = 1, math.floor((script.Parent.Torso.CFrame.p - Target).Magnitude) do
  878. local TR2 = Ray.new(script.Parent.Torso.CFrame.p + (Target - script.Parent.Torso.CFrame.p).Unit * HazardCheck, Vector3.new(0, -50, 0) + (TPos - script.Parent.Torso.CFrame.p).Unit * 3)
  879. local TH2, TP2 = game.Workspace:FindPartOnRay(TR2, script.Parent)
  880. if TH2 ~= nil and TH2.Name ~= "Lava" then
  881. TrueTarget = TP2
  882. else
  883. break
  884. end
  885. end
  886. end
  887. script.Parent.Humanoid:MoveTo(TrueTarget, Current)
  888. end
  889. end
  890. function ZHit(Part)
  891. if script.Parent:FindFirstChild("IsAZombie") ~= nil and script.Parent.Humanoid.Health > 0 and Part ~= nil and Part.Parent ~= nil and Part.Parent:FindFirstChild("Humanoid") ~= nil and Part.Parent:FindFirstChild("IsAZombie") == nil then
  892. Part.Parent.Humanoid:TakeDamage(2)
  893. script.Parent.Humanoid.MaxHealth = script.Parent.Humanoid.MaxHealth + 1
  894. script.Parent.Humanoid:TakeDamage(-1)
  895. end
  896. end
  897. script.Parent["Right Arm"].Touched:connect(ZHit)
  898. script.Parent["Left Arm"].Touched:connect(ZHit)
  899. CurrentMap = {}
  900. MapMask = {}
  901. MapVar = {0, 0, 0, 0, 0}
  902. BlockScanned = 0
  903. ScanSkip = 5
  904. DebugPathing = true
  905. function GenerateMap(PathPos)
  906. CurrentMap = {}
  907. MapMask = {}
  908. MapVar = {0, 0, 0, 0, 0}
  909. BlockScanned = 0
  910. MapVariables = ScanParts(Workspace, 1)
  911. for MapX = 1, math.max(-MapVariables[1], MapVariables[2]) * 2 + 1 do
  912. CurrentMap[MapX] = {}
  913. for MapY = 1, math.max(-MapVariables[3], MapVariables[4]) * 2 + 1 do
  914. CurrentMap[MapX][MapY] = 0
  915. end
  916. end
  917. for MaskX = 1, #CurrentMap do
  918. MapMask[MaskX] = {}
  919. for MaskY = 1, #CurrentMap[MaskX] do
  920. MapMask[MaskX][MaskY] = {MapVariables[1] + MaskX - 0.5, MapVariables[1] + MaskY - 0.5}
  921. end
  922. end
  923. ScanParts(Workspace, 2, MapVariables)
  924. wait(1)
  925. if script.Parent.PrintMap.Value == true then
  926. print("Printing Map...")
  927. for ClearPrint = 1, 250 do
  928. wait()
  929. print()
  930. end
  931. for PrintX = 1, #CurrentMap do
  932. local PrintZ = ""
  933. for PrintY = 1, #CurrentMap[PrintX] do
  934. PrintZ = PrintZ ..CurrentMap[PrintX][PrintY]
  935. end
  936. print(PrintZ)
  937. wait(0.1)
  938. end
  939. end
  940. local MapCoords = {0, 0, 0, 0}
  941. local Distance = math.huge
  942. for MPX = 1, #CurrentMap do
  943. for MPY = 1, #CurrentMap[MPX] do
  944. if (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(script.Parent.Torso.Position.X, 0, script.Parent.Torso.Position.Z)).Magnitude < Distance then
  945. MapCoords = {MPX, MPY, 0, 0}
  946. Distance = (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(script.Parent.Torso.Position.X, 0, script.Parent.Torso.Position.Z)).Magnitude
  947. end
  948. end
  949. end
  950. local Distance = math.huge
  951. for MPX = 1, #CurrentMap do
  952. for MPY = 1, #CurrentMap[MPX] do
  953. if (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(script.Parent.PathTo.Value.X, 0, script.Parent.PathTo.Value.Z)).Magnitude < Distance then
  954. MapCoords = {MapCoords[1], MapCoords[2], math.min(MPX, #CurrentMap) - 1, math.min(MPY, #CurrentMap[1] - 1)}
  955. Distance = (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(script.Parent.PathTo.Value.X, 0, script.Parent.PathTo.Value.Z)).Magnitude
  956. end
  957. end
  958. end
  959. for i, v in pairs(CalcPath(CalcMoves(CurrentMap, MapCoords[1], MapCoords[2], MapCoords[3], MapCoords[4]))) do
  960. local Timer = 20
  961. local pX = v["x"]
  962. local pY = v["y"]
  963. local pTo = Vector3.new(MapMask[pX][pY][1], 0, MapMask[pX][pY][2])
  964. pTo = pTo + (pTo - Vector3.new(script.Parent.Torso.Position.X, 0, script.Parent.Torso.Position.Z)).Unit
  965. while (Vector3.new(script.Parent.Torso.Position.X, 0, script.Parent.Torso.Position.Z) - pTo).Magnitude > 2.5 and Timer > 0 do
  966. script.Parent.Humanoid:MoveTo(pTo, Base)
  967. Timer = Timer - 1
  968. if Timer == 10 then
  969. script.Parent.Humanoid.Jump = true
  970. end
  971. wait(0.1)
  972. end
  973. if Timer == 0 then
  974. if (Vector3.new(script.Parent.Torso.Position.X, 0, script.Parent.Torso.Position.Z) - pTo).Magnitude <= 5 then
  975. script.Parent.Torso.CFrame = script.Parent.Torso.CFrame + (pTo - Vector3.new(script.Parent.Torso.Position.X, 0, script.Parent.Torso.Position.Z)).Unit * (pTo - Vector3.new(script.Parent.Torso.Position.X, 0, script.Parent.Torso.Position.Z)).Magnitude
  976. else
  977. break
  978. end
  979. end
  980. end
  981. end
  982. function ScanParts(CurrentModel, CurrentStage, Variables)
  983. local X = CurrentModel:GetChildren()
  984. for I = 1, #X do
  985. if #X[I]:GetChildren() > 0 then
  986. ScanParts(X[I], 1, Variables)
  987. end
  988. if X[I].ClassName == "Part" or X[I].ClassName == "WedgePart" or X[I].ClassName == "CornerWedgePart" or X[I].ClassName == "TrussPart" or X[I].ClassName == "SpawnLocation" or X[I].ClassName == "Seat" or X[I].ClassName == "VehicleSeat" or X[I].ClassName == "SkateboardPlatform" then
  989. BlockScanned = BlockScanned + 1
  990. if BlockScanned / ScanSkip == math.floor(BlockScanned / ScanSkip) then
  991. wait()
  992. if DebugPathing == true then
  993. print("Block", BlockScanned)
  994. end
  995. end
  996. if CurrentStage == 1 then
  997. MapVar[1] = math.min(math.ceil(X[I].Position.X - X[I].Size.X / 2), MapVar[1])
  998. MapVar[2] = math.max(math.floor(X[I].Position.X + X[I].Size.X / 2), MapVar[2])
  999. MapVar[3] = math.min(math.ceil(X[I].Position.Z - X[I].Size.Z / 2), MapVar[3])
  1000. MapVar[4] = math.max(math.floor(X[I].Position.Z + X[I].Size.Z / 2), MapVar[4])
  1001. elseif CurrentStage == 2 and ((X[I].Position.Y + X[I].Size.Y / 2 > script.Parent.Torso.Position.Y + 2 and X[I].Position.Y - X[I].Size.Y / 2 < script.Parent.Torso.Position.Y + 2) or X[I].Position.Y + X[I].Size.Y / 2 < script.Parent.Torso.Position.Y - 8) then
  1002. local BlockStart = {X[I].Position.X - X[I].Size.X / 2, X[I].Position.Z - X[I].Size.Z / 2}
  1003. local BlockEnd = {X[I].Position.X + X[I].Size.X / 2, X[I].Position.Z + X[I].Size.Z / 2}
  1004. local BlockCoords = {0, 0, 0, 0}
  1005. local Distance = math.huge
  1006. for MPX = 1, #CurrentMap do
  1007. for MPY = 1, #CurrentMap[MPX] do
  1008. if (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(BlockStart[1], 0, BlockStart[2])).Magnitude < Distance then
  1009. BlockCoords = {MPX, MPY, 0, 0}
  1010. Distance = (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(BlockStart[1], 0, BlockStart[2])).Magnitude
  1011. end
  1012. end
  1013. end
  1014. local Distance = math.huge
  1015. for MPX = 1, #CurrentMap do
  1016. for MPY = 1, #CurrentMap[MPX] do
  1017. if (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(BlockEnd[1], 0, BlockEnd[2])).Magnitude < Distance then
  1018. BlockCoords = {BlockCoords[1], BlockCoords[2], MPX, MPY}
  1019. Distance = (Vector3.new(MapMask[MPX][MPY][1], 0, MapMask[MPX][MPY][2]) - Vector3.new(BlockEnd[1], 0, BlockEnd[2])).Magnitude
  1020. end
  1021. end
  1022. end
  1023. for XGrid = BlockCoords[2], BlockCoords[4] do
  1024. for YGrid = BlockCoords[1], BlockCoords[3] do
  1025. CurrentMap[XGrid][YGrid] = 1
  1026. end
  1027. end
  1028. end
  1029. end
  1030. end
  1031. if CurrentStage == 1 then
  1032. MapVar[5] = {MapVar[1] + MapVar[2] / 2, MapVar[3] + MapVar[4] / 2}
  1033. return MapVar
  1034. end
  1035. end
  1036. IsInCombat = false
  1037. while script.Parent.Humanoid.Health > 0 and script.Parent:FindFirstChild("IsAZombie") == nil do
  1038. local Distance = 100
  1039. local Target = nil
  1040. IsInCombat = false
  1041. local Players = Workspace:GetChildren()
  1042. for Check = 1, #Players do
  1043. if Players[Check] ~= script.Parent and ((Players[Check]:FindFirstChild("Humanoid") ~= nil and (Players[Check]:FindFirstChild("IsAZombie") ~= nil or Players[Check]:FindFirstChild("IsLocalEnemy") ~= nil or script.Parent:FindFirstChild("IsLocalEnemy") ~= nil or (script.Parent.IsOnTeam.Value == true and Players[Check]:FindFirstChild("IsOnTeam") ~= nil and Players[Check].IsOnTeam.Value == true and script.Parent.IsOnTeam.Team.Value ~= Players[Check].IsOnTeam.Team.Value) or (game.Players:GetPlayerFromCharacter(Players[Check]) ~= nil and script.Parent.IsOnTeam.Value == true and game.Players:GetPlayerFromCharacter(Players[Check]).Neutral == false and game.Players:GetPlayerFromCharacter(Players[Check]).TeamColor ~= script.Parent.IsOnTeam.Team.Value)) and Players[Check].Humanoid.Health > 0) or (Players[Check]:FindFirstChild("Zombie") ~= nil and Players[Check].Zombie.ClassName == "Humanoid" and Players[Check].Zombie.Health > 0)) and Players[Check]:FindFirstChild("Torso") ~= nil and (Players[Check].Torso.Position - script.Parent.Torso.Position).Magnitude <= 100 then
  1044. local Ray = Ray.new(script.Parent.Torso.CFrame.p, (Players[Check].Torso.CFrame.p - script.Parent.Torso.CFrame.p).Unit * 100)
  1045. local Hit, Position = game.Workspace:FindPartOnRay(Ray, script.Parent)
  1046. if Hit ~= nil and Hit.Parent ~= nil and ((Hit.Parent:FindFirstChild("Humanoid") ~= nil and Hit.Parent == Players[Check]) or (Hit.Parent.Parent ~= nil and Hit.Parent.Parent:FindFirstChild("Humanoid") ~= nil and Hit.Parent.Parent == Players[Check])) then
  1047. local TeamTag = nil
  1048. local Parts = Players[Check]:GetChildren()
  1049. for X = 1, #Parts do
  1050. if Parts[X].Name == "TeamLoc" then
  1051. if Parts[X].Value == script.Parent.IsOnTeam.Team.Value then
  1052. TeamTag = Parts[X]
  1053. end
  1054. end
  1055. end
  1056. if Players[Check]:FindFirstChild("Loc" ..script.Parent.Name) ~= nil or Parts[X] ~= nil or (Players[Check].Torso.Position - (script.Parent.Torso.Position + script.Parent.Torso.CFrame.lookVector * 50)).Magnitude <= 52 then
  1057. if script.Parent.IsOnTeam.Value == false then
  1058. if Players[Check]:FindFirstChild("Loc" ..script.Parent.Name) ~= nil then
  1059. Players[Check]:FindFirstChild("Loc" ..script.Parent.Name):Remove()
  1060. end
  1061. local Found = Instance.new("CFrameValue", Players[Check])
  1062. Found.Name = "Loc" ..script.Parent.Name
  1063. game:GetService("Debris"):AddItem(Found, 3)
  1064. else
  1065. if Parts[X] ~= nil then
  1066. Parts[X]:Remove()
  1067. end
  1068. local Found = Instance.new("BrickColorValue", Players[Check])
  1069. Found.Name = "TeamLoc"
  1070. Found.Value = script.Parent.IsOnTeam.Team.Value
  1071. game:GetService("Debris"):AddItem(Found, 3)
  1072. if Players[Check]:FindFirstChild("Loc" ..script.Parent.Name) ~= nil then
  1073. Players[Check]:FindFirstChild("Loc" ..script.Parent.Name):Remove()
  1074. end
  1075. local Found = Instance.new("CFrameValue", Players[Check])
  1076. Found.Name = "Loc" ..script.Parent.Name
  1077. game:GetService("Debris"):AddItem(Found, 3)
  1078. end
  1079. end
  1080. if Players[Check]:FindFirstChild("Loc" ..script.Parent.Name) ~= nil and (Players[Check].Torso.Position - script.Parent.Torso.Position).Magnitude <= Distance then
  1081. Target = Players[Check].Torso
  1082. Distance = (Target.Position - script.Parent.Torso.Position).Magnitude
  1083. end
  1084. end
  1085. end
  1086. end
  1087. if Target == nil then
  1088. local HasTool = false
  1089. local ToolCheck = script.Parent:GetChildren()
  1090. for Check = 1, #ToolCheck do
  1091. if ToolCheck[Check].ClassName == "Tool" then
  1092. HasTool = true
  1093. end
  1094. end
  1095. if HasTool == false then
  1096. Distance = 100
  1097. for Check = 1, #Players do
  1098. if Players[Check].ClassName == "Tool" and Players[Check]:FindFirstChild("Handle") ~= nil and Players[Check]:FindFirstChild("Active") ~= nil and Players[Check]:FindFirstChild("TargetPos") ~= nil and Players[Check]:FindFirstChild("Type") ~= nil and (Players[Check].Handle.Position - script.Parent.Torso.Position).Magnitude <= Distance then
  1099. local Ray = Ray.new(script.Parent.Torso.CFrame.p, (Players[Check].Handle.CFrame.p - script.Parent.Torso.CFrame.p).Unit * 100)
  1100. local Hit, Position = game.Workspace:FindPartOnRay(Ray, script.Parent)
  1101. if Hit ~= nil and Hit.Parent ~= nil and Hit.Parent == Players[Check] then
  1102. Distance = (Players[Check].Handle.Position - script.Parent.Torso.Position).Magnitude
  1103. Target = Players[Check]
  1104. end
  1105. end
  1106. end
  1107. if Target ~= nil and Target.ClassName == "Tool" then
  1108. if Distance <= 5 and HasTool == false then
  1109. Target.Parent = script.Parent
  1110. HasTool = true
  1111. else
  1112. Prep(Target.Handle.Position, Base)
  1113. end
  1114. else
  1115. for Check = 1, #Players do
  1116. if Players[Check].Name == "Crate" and Players[Check]:FindFirstChild("OpenCrate") ~= nil and Players[Check].OpenCrate.Value == false and (Players[Check].Position - script.Parent.Torso.Position).Magnitude <= Distance then
  1117. local Ray = Ray.new(script.Parent.Torso.CFrame.p, (Players[Check].CFrame.p - script.Parent.Torso.CFrame.p).Unit * 100)
  1118. local Hit, Position = game.Workspace:FindPartOnRay(Ray, script.Parent)
  1119. if Hit ~= nil and Hit == Players[Check] then
  1120. Target = Players[Check]
  1121. Distance = (Target.Position - script.Parent.Torso.Position).Magnitude
  1122. end
  1123. end
  1124. end
  1125. if Target ~= nil then
  1126. script.Parent.Humanoid:MoveTo(Target.Position, Target)
  1127. if (Target.Position - script.Parent.Torso.Position).Magnitude <= 10 then
  1128. Target.OpenCrate.Value = true
  1129. end
  1130. else
  1131. local HasHat = false
  1132. local HatCheck = script.Parent:GetChildren()
  1133. for Check = 1, #HatCheck do
  1134. if ToolCheck[Check].ClassName == "Hat" then
  1135. HasHat = true
  1136. end
  1137. end
  1138. if HasHat == false then
  1139. Distance = 100
  1140. for Check = 1, #Players do
  1141. if Players[Check].ClassName == "Hat" and Players[Check]:FindFirstChild("Handle") ~= nil and (Players[Check].Handle.Position - script.Parent.Torso.Position).Magnitude <= Distance then
  1142. local Ray = Ray.new(script.Parent.Torso.CFrame.p, (Players[Check].Handle.CFrame.p - script.Parent.Torso.CFrame.p).Unit * 100)
  1143. local Hit, Position = game.Workspace:FindPartOnRay(Ray, script.Parent)
  1144. if Hit ~= nil and Hit.Parent ~= nil and Hit.Parent == Players[Check] then
  1145. Distance = (Players[Check].Handle.Position - script.Parent.Torso.Position).Magnitude
  1146. Target = Players[Check]
  1147. end
  1148. end
  1149. end
  1150. if Target ~= nil and Target.ClassName == "Hat" then
  1151. if Distance <= 5 and HasHat == false then
  1152. Target.Parent = script.Parent
  1153. HasHat = true
  1154. else
  1155. Prep(Target.Handle.Position, Base)
  1156. end
  1157. else
  1158. if script.Parent.Humanoid.PlatformStand == false and script.Parent.Humanoid.Sit == false then
  1159. if script.Parent.PathTo.Value ~= Vector3.new(0, 0, 0) then
  1160. GenerateMap(script.Parent.PathTo.Value)
  1161. script.Parent.PathTo.Value = Vector3.new(0, 0, 0)
  1162. elseif math.random(1, 10) == 1 and script.Parent.Wander.Value == true then
  1163. Prep(script.Parent.Torso.Position + Vector3.new(math.random(-100, 100), 0, math.random(-100, 100)), Base)
  1164. end
  1165. else
  1166. Jump()
  1167. end
  1168. end
  1169. end
  1170. end
  1171. end
  1172. else
  1173. if Target == nil then
  1174. local Distance = 80
  1175. local Players = Workspace:GetChildren()
  1176. for Check = 1, #Players do
  1177. if Players[Check]:FindFirstChild("Humanoid") ~= nil and Players[Check] ~= script.Parent and Players[Check]:FindFirstChild("IsLocalEnemy") == nil and Players[Check]:FindFirstChild("Leader") ~= nil and Players[Check].Humanoid.Health > 0 and Players[Check]:FindFirstChild("Torso") ~= nil and (Players[Check].Torso.Position - script.Parent.Torso.Position).Magnitude <= Distance then
  1178. local Ray = Ray.new(script.Parent.Torso.CFrame.p, (Players[Check].Torso.CFrame.p - script.Parent.Torso.CFrame.p).Unit * 100)
  1179. local Hit, Position = game.Workspace:FindPartOnRay(Ray, script.Parent)
  1180. if Hit ~= nil and Hit.Parent ~= nil and ((Hit.Parent:FindFirstChild("Humanoid") ~= nil and Hit.Parent == Players[Check]) or (Hit.Parent.Parent ~= nil and Hit.Parent.Parent:FindFirstChild("Humanoid") ~= nil and Hit.Parent.Parent == Players[Check])) then
  1181. Target = Players[Check].Torso
  1182. Distance = (Target.Position - script.Parent.Torso.Position).Magnitude
  1183. end
  1184. end
  1185. end
  1186. if Target ~= nil then
  1187. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 10
  1188. Prep(Position, Base)
  1189. else
  1190. if script.Parent.Humanoid.PlatformStand == false and script.Parent.Humanoid.Sit == false then
  1191. if script.Parent.PathTo.Value ~= Vector3.new(0, 0, 0) then
  1192. GenerateMap(script.Parent.PathTo.Value)
  1193. script.Parent.PathTo.Value = Vector3.new(0, 0, 0)
  1194. elseif math.random(1, 10) == 1 and script.Parent.Wander.Value == true then
  1195. Prep(script.Parent.Torso.Position + Vector3.new(math.random(-100, 100), 0, math.random(-100, 100)), Base)
  1196. end
  1197. else
  1198. Jump()
  1199. end
  1200. end
  1201. else
  1202. if script.Parent.Humanoid.PlatformStand == false and script.Parent.Humanoid.Sit == false then
  1203. if script.Parent.PathTo.Value ~= Vector3.new(0, 0, 0) then
  1204. GenerateMap(script.Parent.PathTo.Value)
  1205. script.Parent.PathTo.Value = Vector3.new(0, 0, 0)
  1206. elseif math.random(1, 10) == 1 and script.Parent.Wander.Value == true then
  1207. Prep(script.Parent.Torso.Position + Vector3.new(math.random(-100, 100), 0, math.random(-100, 100)), Base)
  1208. end
  1209. else
  1210. Jump()
  1211. end
  1212. end
  1213. end
  1214. else
  1215. local Weapon = nil
  1216. local ToolCheck = script.Parent:GetChildren()
  1217. for Check = 1, #ToolCheck do
  1218. if ToolCheck[Check].ClassName == "Tool" then
  1219. Weapon = ToolCheck[Check]
  1220. end
  1221. end
  1222. if Weapon ~= nil and Weapon:FindFirstChild("Active") ~= nil and Weapon:FindFirstChild("TargetPos") ~= nil and Weapon:FindFirstChild("Type") ~= nil then
  1223. if Weapon.Type.Value == "Melee" then
  1224. Prep(Target.Position + Vector3.new(math.random(-3, 3), 0, math.random(-3, 3)), Target)
  1225. if (Target.Position - script.Parent.Torso.Position).Magnitude <= 10 then
  1226. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1227. Weapon.Active.Value = true
  1228. end
  1229. elseif Weapon.Type.Value == "Melee/Ranged" then
  1230. if Distance <= 10 then
  1231. Prep(Target.Position + Vector3.new(math.random(-3, 3), 0, math.random(-3, 3)), Target)
  1232. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1233. Weapon.Active.Value = true
  1234. else
  1235. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 40, Base)
  1236. if (Target.Position - script.Parent.Torso.Position).Magnitude <= 50 then
  1237. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1238. Weapon.Active.Value = true
  1239. end
  1240. end
  1241. elseif Weapon.Type.Value == "Melee/RangedMed" then
  1242. if Distance <= 10 then
  1243. Prep(Target.Position + Vector3.new(math.random(-3, 3), 0, math.random(-3, 3)), Target)
  1244. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1245. Weapon.Active.Value = true
  1246. else
  1247. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 30, Base)
  1248. if (Target.Position - script.Parent.Torso.Position).Magnitude <= 40 then
  1249. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1250. Weapon.Active.Value = true
  1251. end
  1252. end
  1253. elseif Weapon.Type.Value == "Melee/RangedClose" then
  1254. if Distance <= 10 then
  1255. Prep(Target.Position + Vector3.new(math.random(-3, 3), 0, math.random(-3, 3)), Target)
  1256. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1257. Weapon.Active.Value = true
  1258. else
  1259. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 20, Base)
  1260. if (Target.Position - script.Parent.Torso.Position).Magnitude <= 30 then
  1261. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1262. Weapon.Active.Value = true
  1263. end
  1264. end
  1265. elseif Weapon.Type.Value == "Ranged" then
  1266. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 80, Base)
  1267. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1268. wait()
  1269. Weapon.Active.Value = true
  1270. elseif Weapon.Type.Value == "RangedMed" then
  1271. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 60, Base)
  1272. if Distance <= 70 then
  1273. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1274. wait()
  1275. Weapon.Active.Value = true
  1276. end
  1277. elseif Weapon.Type.Value == "RangedClose" then
  1278. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 30, Base)
  1279. if Distance <= 40 then
  1280. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1281. wait()
  1282. Weapon.Active.Value = true
  1283. end
  1284. elseif Weapon.Type.Value == "RangedAngle" and Distance <= 100 then
  1285. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * (script.Parent.Torso.Position - Target.Position).Magnitude + Target.Velocity
  1286. script.Parent.Humanoid:MoveTo(Position, Base)
  1287. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1288. wait()
  1289. Weapon.Active.Value = true
  1290. elseif Weapon.Type.Value == "RangedTactical" then
  1291. if Distance <= 30 then
  1292. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 50
  1293. Prep(Position, Base)
  1294. elseif Distance >= 50 then
  1295. Prep(Target.Position, Target)
  1296. end
  1297. if Distance <= 50 and Distance >= 30 then
  1298. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 40, Target.Parent.Torso)
  1299. end
  1300. if Distance <= 60 then
  1301. Weapon.TargetPos.Value = Target.Position + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1302. wait()
  1303. Weapon.Active.Value = true
  1304. end
  1305. elseif Weapon.Type.Value == "Shuriken" then
  1306. if Distance <= 15 then
  1307. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 20
  1308. Prep(Position, Base)
  1309. elseif Distance >= 30 then
  1310. Prep(Target.Position, Target)
  1311. end
  1312. if Distance <= 30 and Distance >= 15 then
  1313. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 20, Target.Parent.Torso)
  1314. end
  1315. if Distance <= 50 then
  1316. Weapon.TargetPos.Value = (Target.Position + Target.Velocity / 2) + Vector3.new(math.random(-2, 2), math.random(-2, 2) + ((Target.Position + Target.Velocity / 2) - script.Parent.Torso.Position).Magnitude / 8, math.random(-2, 2))
  1317. wait()
  1318. Weapon.Active.Value = true
  1319. end
  1320. elseif Weapon.Type.Value == "HealDrink" then
  1321. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 120
  1322. Prep(Position, Base)
  1323. if script.Parent.Humanoid.Health < script.Parent.Humanoid.MaxHealth then
  1324. Weapon.Active.Value = true
  1325. end
  1326. elseif Weapon.Type.Value == "GrenadeDirect" then
  1327. if Distance >= 80 and Distance <= 100 then
  1328. Prep(Target.Position, Target)
  1329. wait(0.5)
  1330. Weapon.Active.Value = true
  1331. wait(0.5)
  1332. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 100
  1333. Prep(Position, Base)
  1334. else
  1335. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 100
  1336. Prep(Position, Base)
  1337. end
  1338. elseif Weapon.Type.Value == "Bomb" then
  1339. if Distance > 10 then
  1340. Prep(Target.Position, Target)
  1341. elseif Distance <= 10 then
  1342. Weapon.Active.Value = true
  1343. wait(2)
  1344. while Weapon ~= nil and Weapon:FindFirstChild("Handle") ~= nil and Weapon.Handle.Transparency == 1 do
  1345. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 80, Base)
  1346. wait(0.5)
  1347. end
  1348. end
  1349. elseif Weapon.Type.Value == "Backstab" then
  1350. if Distance >= 10 then
  1351. if (script.Parent.Torso.Position - (Target.Position + Target.CFrame.lookVector * 50)).Magnitude <= 52 then
  1352. Prep(Target.Position, Target)
  1353. else
  1354. if (script.Parent.Torso.Position - (Target.Position - Target.CFrame.lookVector * 15)).Magnitude <= 5 then
  1355. Prep(Target.Position, Base)
  1356. local backstab_time = 20
  1357. while backstab_time > 1 and (script.Parent.Torso.Position - Target.Position).Magnitude >= 4 do
  1358. wait(0.1)
  1359. backstab_time = backstab_time - 1
  1360. end
  1361. if (script.Parent.Torso.Position - Target.Position).Magnitude < 4 then
  1362. Weapon.Active.Value = true
  1363. end
  1364. else
  1365. Prep(Target.Position - Target.CFrame.lookVector * 15, Base)
  1366. end
  1367. end
  1368. else
  1369. Prep(Target.Position + Vector3.new(math.random(-2, 2), 0, math.random(-2, 2)), Target)
  1370. if Distance <= 5 then
  1371. Weapon.Active.Value = true
  1372. end
  1373. end
  1374. elseif Weapon.Type.Value == "Crossbow" then
  1375. if Distance > 80 then
  1376. Prep(Target.Position, Target)
  1377. elseif Distance < 40 then
  1378. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 100, Base)
  1379. elseif Distance <= 80 and Distance >= 40 then
  1380. Prep(Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * ((script.Parent.Torso.Position - Target.Position).Magnitude - 5), Base)
  1381. wait(0.2)
  1382. Weapon.TargetPos.Value = Target.Position + Target.Velocity / 8 + Vector3.new(math.random(-2, 2), math.random(-2, 2), math.random(-2, 2))
  1383. Weapon.Active.Value = true
  1384. end
  1385. end
  1386. IsInCombat = true
  1387. elseif Distance <= 100 then
  1388. local Position = Target.Position + (script.Parent.Torso.Position - Target.Position).Unit * 120
  1389. Prep(Position, Base)
  1390. end
  1391. end
  1392. if IsInCombat == true then
  1393. wait(0.2)
  1394. else
  1395. wait(0.6)
  1396. end
  1397. end
  1398. local Weapon = nil
  1399. local ToolCheck = script.Parent:GetChildren()
  1400. for Check = 1, #ToolCheck do
  1401. if ToolCheck[Check].ClassName == "Tool" then
  1402. Weapon = ToolCheck[Check]
  1403. end
  1404. end
  1405. if Weapon ~= nil and script.Parent.DropWeapon.Value == true then
  1406. Weapon.Parent = Workspace
  1407. elseif Weapon ~= nil then
  1408. Weapon:Remove()
  1409. end
  1410. if script.Parent:FindFirstChild("IsAZombie") ~= nil then
  1411. script.Parent.Name = "New Zombie"
  1412. script.Parent.Humanoid.MaxHealth = script.Parent.Humanoid.MaxHealth + math.random(math.random(-50, -25), math.random(25, math.random(50, 100)))
  1413. wait()
  1414. script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
  1415. script.Parent.Humanoid.WalkSpeed = script.Parent.Humanoid.WalkSpeed + math.random(math.random(-200, 0), math.random(100, math.random(200, 300))) / 100
  1416. ZStat = 2
  1417. ZStat2 = 1.57
  1418. Delay(1, function()
  1419. while script.Parent:FindFirstChild("Humanoid") ~= nil and script.Parent.Humanoid.Health > 0 do
  1420. script.Parent.Humanoid.MaxHealth = math.max(0, script.Parent.Humanoid.MaxHealth - 1)
  1421. script.Parent.Humanoid.Health = math.min(script.Parent.Humanoid.Health, script.Parent.Humanoid.MaxHealth)
  1422. wait(1)
  1423. end
  1424. end)
  1425. while script.Parent.Humanoid.Health > 0 and script.Parent:FindFirstChild("IsAZombie") ~= nil do
  1426. local Distance = 100
  1427. local Target = nil
  1428. local Players = Workspace:GetChildren()
  1429. for Check = 1, #Players do
  1430. if Players[Check]:FindFirstChild("Humanoid") ~= nil and Players[Check]:FindFirstChild("Torso") ~= nil and Players[Check]:FindFirstChild("IsAZombie") == nil and Players[Check].Humanoid.Health > 0 and (Players[Check].Torso.Position - script.Parent.Torso.Position).Magnitude <= 100 then
  1431. local ZRay = Ray.new(script.Parent.Torso.CFrame.p, (Players[Check].Torso.CFrame.p - script.Parent.Torso.CFrame.p).Unit * 100)
  1432. local ZHit, ZPos = Workspace:FindPartOnRay(ZRay, script.Parent)
  1433. if Players[Check]:FindFirstChild("ZFound") ~= nil or (ZHit ~= nil and ZHit.Parent ~= nil and ZHit.Parent.Parent ~= nil and (ZHit.Parent == Players[Check] or ZHit.Parent.Parent == Players[Check])) then
  1434. if ZHit ~= nil and ZHit.Parent ~= nil and ZHit.Parent.Parent ~= nil and (ZHit.Parent == Players[Check] or ZHit.Parent.Parent == Players[Check]) then
  1435. if Players[Check]:FindFirstChild("ZFound") ~= nil then
  1436. Players[Check].ZFound:Remove()
  1437. end
  1438. local ZTag = Instance.new("CFrameValue", Players[Check])
  1439. ZTag.Name = "ZFound"
  1440. game:GetService("Debris"):AddItem(ZTag, 5)
  1441. end
  1442. if (Players[Check].Torso.Position - script.Parent.Torso.Position).Magnitude <= Distance then
  1443. Target = Players[Check].Torso
  1444. Distance = (Target.Position - script.Parent.Torso.Position).Magnitude
  1445. end
  1446. end
  1447. end
  1448. end
  1449. if Target == nil then
  1450. if script.Parent.Humanoid.PlatformStand == false and script.Parent.Humanoid.Sit == false then
  1451. if math.random(1, 10) == 1 and script.Parent.Wander.Value == true then
  1452. Prep(script.Parent.Torso.Position + Vector3.new(math.random(-100, 100), 0, math.random(-100, 100)), Base)
  1453. end
  1454. else
  1455. Jump()
  1456. end
  1457. elseif script.Parent.Wander.Value == true then
  1458. script.Parent.Humanoid:MoveTo(Target.Position + Vector3.new(math.random(-2, 2), 0, math.random(-2, 2)), Target)
  1459. end
  1460. wait(0.8)
  1461. end
  1462. end
  1463. end)
  1464. Delay(0, function() --Random Tool Usage Script
  1465. while true do
  1466. wait(math.random(40, 70 + math.random(30, 120)) / 10)
  1467. local Weapon = nil
  1468. local ToolCheck = script.Parent:GetChildren()
  1469. for Check = 1, #ToolCheck do
  1470. if ToolCheck[Check].ClassName == "Tool" then
  1471. Weapon = ToolCheck[Check]
  1472. end
  1473. end
  1474. if Weapon ~= nil and Weapon:FindFirstChild("Active") ~= nil and Weapon:FindFirstChild("TargetPos") ~= nil and Weapon:FindFirstChild("Type") ~= nil then
  1475. if Weapon.Type.Value == "HealDrink" then
  1476. Weapon.Active.Value = true
  1477. end
  1478. end
  1479. end
  1480. end)
  1481. Delay(1, function() --Player Customization Script
  1482. if script.Parent["Custom_Name"].Value == "" then
  1483. script.Parent.Name = "Player" ..math.random(1, 999)
  1484. else
  1485. script.Parent.Name = script.Parent["Custom_Name"].Value
  1486. end
  1487. BColors = {3, 5, 12, 18, 108, 128, 138, 224, 224, 226, 226}
  1488. SColors = {145, 146, 147, 148, 149, 150, 168, 176, 178, 179, 200}
  1489. PColors = {190, 191, 193, 1024, 1025, 1026, 1027, 1028, 1029, 1030}
  1490. BColor = BrickColor.new(BColors[math.random(1, #BColors)])
  1491. SColor = BrickColor.new(SColors[math.random(1, #SColors)])
  1492. PColor = BrickColor.new(PColors[math.random(1, #PColors)])
  1493. if script.Parent.IsOnTeam.Value == true then
  1494. SColor = script.Parent.IsOnTeam.Team.Value
  1495. PColor = SColor
  1496. if script.Parent.IsOnTeam.ShowTag.Value == true then
  1497. script.Parent.Name = script.Parent.Name .." [" ..script.Parent.IsOnTeam.Team.Value.Name .."]"
  1498. end
  1499. end
  1500. if script.Parent["Body Colors"].ForceColors.Value ~= true then
  1501. script.Parent["Body Colors"].HeadColor = BColor
  1502. script.Parent["Body Colors"].LeftArmColor = BColor
  1503. script.Parent["Body Colors"].LeftLegColor = PColor
  1504. script.Parent["Body Colors"].RightArmColor = BColor
  1505. script.Parent["Body Colors"].RightLegColor = PColor
  1506. script.Parent["Body Colors"].TorsoColor = SColor
  1507. end
  1508. script.Parent.Head.BrickColor = script.Parent["Body Colors"].HeadColor
  1509. script.Parent["Left Arm"].BrickColor = script.Parent["Body Colors"].LeftArmColor
  1510. script.Parent["Left Leg"].BrickColor = script.Parent["Body Colors"].LeftLegColor
  1511. script.Parent["Right Arm"].BrickColor = script.Parent["Body Colors"].RightArmColor
  1512. script.Parent["Right Leg"].BrickColor = script.Parent["Body Colors"].RightLegColor
  1513. script.Parent.Torso.BrickColor = script.Parent["Body Colors"].TorsoColor
  1514. if script.Parent["Force_Weapon"].Value ~= 0 then
  1515. local x = game:GetService("InsertService"):LoadAsset(script.Parent["Force_Weapon"].Value)
  1516. local c = x:GetChildren()
  1517. for i = 1, #c do
  1518. if c[i].ClassName == "Tool" and c[i]:FindFirstChild("AIProgram") ~= nil and c[i]:FindFirstChild("Active") ~= nil and c[i]:FindFirstChild("TargetPos") ~= nil and c[i]:FindFirstChild("Type") ~= nil and c[i]:FindFirstChild("Handle") ~= nil then
  1519. c[i].Parent = script.Parent
  1520. script.Parent.DropWeapon.Value = false
  1521. end
  1522. end
  1523. end
  1524. if script.Parent["Force_Hat"].Value ~= 0 then
  1525. local x = game:GetService("InsertService"):LoadAsset(script.Parent["Force_Hat"].Value)
  1526. local c = x:GetChildren()
  1527. for i = 1, #c do
  1528. if c[i].ClassName == "Hat" and c[i]:FindFirstChild("Handle") ~= nil then
  1529. c[i].Parent = script.Parent
  1530. end
  1531. end
  1532. end
  1533. if script.Parent["Force_Shirt"].Value ~= 0 then
  1534. local x = game:GetService("InsertService"):LoadAsset(script.Parent["Force_Shirt"].Value)
  1535. local c = x:GetChildren()
  1536. for i = 1, #c do
  1537. if c[i].ClassName == "Shirt" then
  1538. c[i].Parent = script.Parent
  1539. end
  1540. end
  1541. end
  1542. if script.Parent["Force_Pants"].Value ~= 0 then
  1543. local x = game:GetService("InsertService"):LoadAsset(script.Parent["Force_Pants"].Value)
  1544. local c = x:GetChildren()
  1545. for i = 1, #c do
  1546. if c[i].ClassName == "Pants" then
  1547. c[i].Parent = script.Parent
  1548. end
  1549. end
  1550. end
  1551. end)
  1552. wait()
  1553. print("Player Bot Loaded")
  1554. end))
  1555. IntValue30.Name = "Force_Hat"
  1556. IntValue30.Parent = Model0
  1557. IntValue31.Name = "Force_Shirt"
  1558. IntValue31.Parent = Model0
  1559. IntValue32.Name = "Force_Pants"
  1560. IntValue32.Parent = Model0
  1561. Script33.Name = "Disintegrate"
  1562. Script33.Parent = Model0
  1563. table.insert(cors,sandbox(Script33,function()
  1564. local t = game:GetService("TweenService")
  1565.  
  1566. script.Parent.Humanoid.Died:Connect(function()
  1567. local c = script.Parent:GetDescendants()
  1568. local p = {}
  1569. for x=1,#c do
  1570. if c[x]:IsA("BasePart") then
  1571. p[#p+1] = c[x]
  1572. c[x].Anchored = true
  1573. elseif c[x]:IsA("Decal") then
  1574. local tween = t:Create(c[x],TweenInfo.new(1),{Transparency = 1})
  1575. tween:Play()
  1576. end
  1577. end
  1578. for x=1,#p do
  1579. local tween = t:Create(p[x],TweenInfo.new(1),{Transparency = 1})
  1580. tween:Play()
  1581. if p[x].Parent == script.Parent then
  1582. local picle = script.Dust:Clone()
  1583. picle.Color = ColorSequence.new(p[x].Color)
  1584. picle.Parent = p[x]
  1585. p[x].Dust:Emit(10*math.abs(p[x].Size.magnitude))
  1586. end
  1587. wait(.1)
  1588. end
  1589. end)
  1590. end))
  1591. ParticleEmitter34.Name = "Dust"
  1592. ParticleEmitter34.Parent = Script33
  1593. ParticleEmitter34.Speed = NumberRange.new(2, 6)
  1594. ParticleEmitter34.Rotation = NumberRange.new(-180, 180)
  1595. ParticleEmitter34.Color = ColorSequence.new(Color3.new(0.686275, 0.509804, 0.294118),Color3.new(0.686275, 0.509804, 0.294118))
  1596. ParticleEmitter34.Enabled = false
  1597. ParticleEmitter34.LightInfluence = 1
  1598. ParticleEmitter34.Texture = "rbxassetid://282305485"
  1599. ParticleEmitter34.Transparency = NumberSequence.new(1,0.20000000298023,1)
  1600. ParticleEmitter34.Size = NumberSequence.new(0.20000000298023,0)
  1601. ParticleEmitter34.Acceleration = Vector3.new(0, 2, 0)
  1602. ParticleEmitter34.EmissionDirection = Enum.NormalId.Left
  1603. ParticleEmitter34.Lifetime = NumberRange.new(0.5, 2)
  1604. ParticleEmitter34.RotSpeed = NumberRange.new(-50, 50)
  1605. ParticleEmitter34.SpreadAngle = Vector2.new(45, 10)
  1606. ParticleEmitter34.VelocitySpread = 45
  1607. for i,v in pairs(mas:GetChildren()) do
  1608. v.Parent = script
  1609. pcall(function() v:MakeJoints() end)
  1610. end
  1611. mas:Destroy()
  1612. for i,v in pairs(cors) do
  1613. spawn(function()
  1614. pcall(v)
  1615. end)
  1616. end
Advertisement
Add Comment
Please, Sign In to add comment