sIendytubble

npc script

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