sawgamer1

Untitled

Jun 24th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.91 KB | None | 0 0
  1. --Created with PenguinAnonymous's compiler
  2. --PenguinAnonymous is not responsible for damages caused to your game
  3. --This plugin does not remove things
  4. --PenguinAnonymous cannot be held resonsible for manual deletion for the purpose of testing
  5. --Keep in mind, any items that cause errors in compilation will be skipped and documented within the last line of the disclaimer comments
  6. --Thank you for using my plugin and enjoy :)
  7. --It is free to use
  8. --If you use this plugin to create your own, please give me credit
  9. --Z_V edited my plugin to look like his own and published it without giving me credit, and that makes me very angry
  10. --Errors: ChorusSoundEffect
  11. local runDummyScript = function(f,scri)
  12. local oldenv = getfenv(f)
  13. local newenv = setmetatable({}, {
  14. __index = function(_, k)
  15. if k:lower() == 'script' then
  16. return scri
  17. else
  18. return oldenv[k]
  19. end
  20. end
  21. })
  22. setfenv(f, newenv)
  23. ypcall(function() f() end)
  24. end
  25. cors = {}
  26. mas = Instance.new("Model",game:GetService("Lighting"))
  27. mas.Name = "CompiledModel"
  28. o1 = Instance.new("Model")
  29. o2 = Instance.new("Part")
  30. o3 = Instance.new("Motor6D")
  31. o4 = Instance.new("Script")
  32. o5 = Instance.new("ScreenGui")
  33. o6 = Instance.new("Frame")
  34. o7 = Instance.new("Sound")
  35. o9 = Instance.new("Part")
  36. o10 = Instance.new("Motor6D")
  37. o11 = Instance.new("Motor6D")
  38. o12 = Instance.new("Motor6D")
  39. o13 = Instance.new("Motor6D")
  40. o14 = Instance.new("Motor6D")
  41. o15 = Instance.new("Part")
  42. o16 = Instance.new("Part")
  43. o17 = Instance.new("Part")
  44. o18 = Instance.new("Part")
  45. o19 = Instance.new("Part")
  46. o20 = Instance.new("SpecialMesh")
  47. o21 = Instance.new("Decal")
  48. o22 = Instance.new("Decal")
  49. o23 = Instance.new("Humanoid")
  50. o24 = Instance.new("BindableEvent")
  51. o25 = Instance.new("Script")
  52. o26 = Instance.new("StringValue")
  53. o27 = Instance.new("Animation")
  54. o28 = Instance.new("StringValue")
  55. o29 = Instance.new("Animation")
  56. o30 = Instance.new("StringValue")
  57. o31 = Instance.new("Animation")
  58. o32 = Instance.new("NumberValue")
  59. o33 = Instance.new("Animation")
  60. o34 = Instance.new("NumberValue")
  61. o35 = Instance.new("StringValue")
  62. o36 = Instance.new("Animation")
  63. o37 = Instance.new("StringValue")
  64. o38 = Instance.new("Animation")
  65. o39 = Instance.new("StringValue")
  66. o40 = Instance.new("Animation")
  67. o41 = Instance.new("StringValue")
  68. o42 = Instance.new("Animation")
  69. o43 = Instance.new("StringValue")
  70. o44 = Instance.new("Animation")
  71. o45 = Instance.new("Script")
  72. o46 = Instance.new("Animation")
  73. o47 = Instance.new("Configuration")
  74. o48 = Instance.new("NumberValue")
  75. o49 = Instance.new("BoolValue")
  76. o50 = Instance.new("BoolValue")
  77. o51 = Instance.new("Vector3Value")
  78. o52 = Instance.new("BoolValue")
  79. o53 = Instance.new("BrickColorValue")
  80. o54 = Instance.new("NumberValue")
  81. o55 = Instance.new("NumberValue")
  82. o56 = Instance.new("NumberValue")
  83. o57 = Instance.new("Configuration")
  84. o58 = Instance.new("ObjectValue")
  85. o59 = Instance.new("BindableEvent")
  86. o60 = Instance.new("BindableFunction")
  87. o61 = Instance.new("BindableEvent")
  88. o62 = Instance.new("Model")
  89. o1.Name = "Nightmare.exe"
  90. o1.Parent = mas
  91. o2.Name = "HumanoidRootPart"
  92. o2.Parent = o1
  93. o2.BrickColor = BrickColor.new("Pastel blue-green")
  94. o2.Transparency = 1
  95. o2.Position = Vector3.new(-42.8143806, 5.49803114, 31.3534012)
  96. o2.Rotation = Vector3.new(0, -5.96000004, 0)
  97. o2.FormFactor = Enum.FormFactor.Symmetric
  98. o2.Size = Vector3.new(2.33199978, 2.33199978, 1.16599989)
  99. o2.CFrame = CFrame.new(-42.8143806, 5.49803114, 31.3534012, 0.994588196, 0, -0.103896089, 0, 1, 0, 0.103896089, 0, 0.994588196)
  100. o2.BottomSurface = Enum.SurfaceType.Smooth
  101. o2.TopSurface = Enum.SurfaceType.Smooth
  102. o2.Color = Color3.new(0.623529, 0.952941, 0.913726)
  103. o2.Position = Vector3.new(-42.8143806, 5.49803114, 31.3534012)
  104. o3.Name = "Root Hip"
  105. o3.Parent = o2
  106. o3.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  107. o3.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  108. o3.Part0 = o2
  109. o3.Part1 = o9
  110. o3.MaxVelocity = 0.10000000149012
  111. o4.Name = "ScaryScript"
  112. o4.Parent = o2
  113. table.insert(cors,coroutine.create(function()
  114. wait()
  115. runDummyScript(function()
  116. Sound = script.Parent.Scream
  117. Popup = script.Parent.Popup
  118. Ready = true
  119. function onTouch(hit)
  120. local h = hit.Parent:FindFirstChild("Humanoid")
  121. if h ~= nil and Ready == true then
  122. Ready = false
  123. local plyr = game.Players:FindFirstChild(h.Parent.Name)
  124. local c = Popup:clone()
  125. c.Parent = plyr.PlayerGui
  126. script.Parent.Scream:play()
  127. wait(2)
  128. c:remove()
  129. wait(1)
  130. Ready = true
  131. end
  132. end
  133.  
  134. script.Parent.Touched:connect(onTouch)
  135.  
  136. end,o4)
  137. end))
  138. o5.Name = "Popup"
  139. o5.Parent = o2
  140. o6.Name = "BackGround"
  141. o6.Parent = o5
  142. o6.Position = UDim2.new(0,0,-0.10000000149012,0)
  143. o6.Size = UDim2.new(1.1000000238419,0,1.2000000476837,0)
  144. o6.Position = UDim2.new(0,0,-0.10000000149012,0)
  145. o6.BackgroundColor3 = Color3.new(0.109804, 0.109804, 0.109804)
  146. o6.BackgroundTransparency = 1
  147. o7.Name = "Scream"
  148. o7.Parent = o2
  149. o7.SoundId = "rbxassetid://464710503"
  150. o9.Name = "Torso"
  151. o9.Parent = o1
  152. o9.BrickColor = BrickColor.new("Pastel blue-green")
  153. o9.Position = Vector3.new(-42.8143806, 5.49803114, 31.3534012)
  154. o9.Rotation = Vector3.new(0, -5.96000004, 0)
  155. o9.FormFactor = Enum.FormFactor.Symmetric
  156. o9.Size = Vector3.new(2.33199978, 2.33199978, 1.16599989)
  157. o9.CFrame = CFrame.new(-42.8143806, 5.49803114, 31.3534012, 0.994588196, 0, -0.103896089, 0, 1, 0, 0.103896089, 0, 0.994588196)
  158. o9.BottomSurface = Enum.SurfaceType.Smooth
  159. o9.TopSurface = Enum.SurfaceType.Smooth
  160. o9.Color = Color3.new(0.623529, 0.952941, 0.913726)
  161. o9.Position = Vector3.new(-42.8143806, 5.49803114, 31.3534012)
  162. o10.Name = "Left Hip"
  163. o10.Parent = o9
  164. o10.C0 = CFrame.new(-1.16599989, -1.16599989, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  165. o10.C1 = CFrame.new(-0.582999945, 1.16599989, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  166. o10.Part0 = o9
  167. o10.Part1 = o15
  168. o10.MaxVelocity = 0.10000000149012
  169. o11.Name = "Right Hip"
  170. o11.Parent = o9
  171. o11.C0 = CFrame.new(1.16599989, -1.16599989, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  172. o11.C1 = CFrame.new(0.582999945, 1.16599989, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  173. o11.Part0 = o9
  174. o11.Part1 = o16
  175. o11.MaxVelocity = 0.10000000149012
  176. o12.Name = "Left Shoulder"
  177. o12.Parent = o9
  178. o12.C0 = CFrame.new(-1.16599989, 0.582999945, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  179. o12.C1 = CFrame.new(0.582999945, 0.582999945, 0, -4.37113883e-08, 0, -1, 0, 0.99999994, 0, 1, 0, -4.37113883e-08)
  180. o12.Part0 = o9
  181. o12.Part1 = o17
  182. o12.MaxVelocity = 0.10000000149012
  183. o13.Name = "Right Shoulder"
  184. o13.Parent = o9
  185. o13.C0 = CFrame.new(1.16599989, 0.582999945, 0, -4.37113883e-08, 0, 1, -0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  186. o13.C1 = CFrame.new(-0.582999945, 0.582999945, 0, -4.37113883e-08, 0, 1, 0, 0.99999994, 0, -1, 0, -4.37113883e-08)
  187. o13.Part0 = o9
  188. o13.Part1 = o18
  189. o13.MaxVelocity = 0.10000000149012
  190. o14.Name = "Neck"
  191. o14.Parent = o9
  192. o14.C0 = CFrame.new(0, 1.16599989, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  193. o14.C1 = CFrame.new(0, -0.582999945, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  194. o14.Part0 = o9
  195. o14.Part1 = o19
  196. o14.MaxVelocity = 0.10000000149012
  197. o15.Name = "Left Leg"
  198. o15.Parent = o1
  199. o15.BrickColor = BrickColor.new("Pastel blue-green")
  200. o15.Position = Vector3.new(-43.3942261, 3.1660316, 31.2928295)
  201. o15.Rotation = Vector3.new(0, -5.96000004, 0)
  202. o15.FormFactor = Enum.FormFactor.Symmetric
  203. o15.Size = Vector3.new(1.16599989, 2.33199978, 1.16599989)
  204. o15.CFrame = CFrame.new(-43.3942261, 3.1660316, 31.2928295, 0.994588196, 0, -0.103896089, 0, 0.999999881, 0, 0.103896089, 0, 0.994588196)
  205. o15.BottomSurface = Enum.SurfaceType.Smooth
  206. o15.TopSurface = Enum.SurfaceType.Smooth
  207. o15.Color = Color3.new(0.623529, 0.952941, 0.913726)
  208. o15.Position = Vector3.new(-43.3942261, 3.1660316, 31.2928295)
  209. o16.Name = "Right Leg"
  210. o16.Parent = o1
  211. o16.BrickColor = BrickColor.new("Pastel blue-green")
  212. o16.Position = Vector3.new(-42.2345352, 3.1660316, 31.4139729)
  213. o16.Rotation = Vector3.new(0, -5.96000004, 0)
  214. o16.FormFactor = Enum.FormFactor.Symmetric
  215. o16.Size = Vector3.new(1.16599989, 2.33199978, 1.16599989)
  216. o16.CFrame = CFrame.new(-42.2345352, 3.1660316, 31.4139729, 0.994588196, 0, -0.103896089, 0, 0.999999881, 0, 0.103896089, 0, 0.994588196)
  217. o16.BottomSurface = Enum.SurfaceType.Smooth
  218. o16.TopSurface = Enum.SurfaceType.Smooth
  219. o16.Color = Color3.new(0.623529, 0.952941, 0.913726)
  220. o16.Position = Vector3.new(-42.2345352, 3.1660316, 31.4139729)
  221. o17.Name = "Left Arm"
  222. o17.Parent = o1
  223. o17.BrickColor = BrickColor.new("Pastel blue-green")
  224. o17.Position = Vector3.new(-44.5539169, 5.49803114, 31.1716862)
  225. o17.Rotation = Vector3.new(0, -5.96000004, 0)
  226. o17.FormFactor = Enum.FormFactor.Symmetric
  227. o17.Size = Vector3.new(1.16599989, 2.33199978, 1.16599989)
  228. o17.CFrame = CFrame.new(-44.5539169, 5.49803114, 31.1716862, 0.994588196, 0, -0.103896089, 0, 0.999999881, 0, 0.103896089, 0, 0.994588196)
  229. o17.BottomSurface = Enum.SurfaceType.Smooth
  230. o17.TopSurface = Enum.SurfaceType.Smooth
  231. o17.Color = Color3.new(0.623529, 0.952941, 0.913726)
  232. o17.Position = Vector3.new(-44.5539169, 5.49803114, 31.1716862)
  233. o18.Name = "Right Arm"
  234. o18.Parent = o1
  235. o18.BrickColor = BrickColor.new("Pastel blue-green")
  236. o18.Position = Vector3.new(-41.0748444, 5.49803114, 31.5351162)
  237. o18.Rotation = Vector3.new(0, -5.96000004, 0)
  238. o18.FormFactor = Enum.FormFactor.Symmetric
  239. o18.Size = Vector3.new(1.16599989, 2.33199978, 1.16599989)
  240. o18.CFrame = CFrame.new(-41.0748444, 5.49803114, 31.5351162, 0.994588196, 0, -0.103896089, 0, 0.999999881, 0, 0.103896089, 0, 0.994588196)
  241. o18.BottomSurface = Enum.SurfaceType.Smooth
  242. o18.TopSurface = Enum.SurfaceType.Smooth
  243. o18.Color = Color3.new(0.623529, 0.952941, 0.913726)
  244. o18.Position = Vector3.new(-41.0748444, 5.49803114, 31.5351162)
  245. o19.Name = "Head"
  246. o19.Parent = o1
  247. o19.BrickColor = BrickColor.new("Pastel blue-green")
  248. o19.Position = Vector3.new(-42.8143806, 7.24703121, 31.3534012)
  249. o19.Rotation = Vector3.new(0, -5.96000004, 0)
  250. o19.FormFactor = Enum.FormFactor.Symmetric
  251. o19.Size = Vector3.new(2.33199978, 1.16599989, 1.16599989)
  252. o19.CFrame = CFrame.new(-42.8143806, 7.24703121, 31.3534012, 0.994588196, 0, -0.103896089, 0, 1, 0, 0.103896089, 0, 0.994588196)
  253. o19.BottomSurface = Enum.SurfaceType.Smooth
  254. o19.TopSurface = Enum.SurfaceType.Smooth
  255. o19.Color = Color3.new(0.623529, 0.952941, 0.913726)
  256. o19.Position = Vector3.new(-42.8143806, 7.24703121, 31.3534012)
  257. o20.Parent = o19
  258. o20.Scale = Vector3.new(1.25, 1.25, 1.25)
  259. o21.Parent = o19
  260. o21.Texture = "http://www.roblox.com/asset/?id=291716137"
  261. o21.Face = Enum.NormalId.Left
  262. o22.Parent = o19
  263. o22.Texture = "http://www.roblox.com/asset/?id=291716137"
  264. o23.Parent = o1
  265. o23.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
  266. o23.NameOcclusion = Enum.NameOcclusion.NoOcclusion
  267. o23.RightLeg = o16
  268. o23.LeftLeg = o15
  269. o23.Torso = o2
  270. o23.Health = 170
  271. o23.MaxHealth = 170
  272. o23.WalkSpeed = 20
  273. o24.Name = "Attacked"
  274. o24.Parent = o1
  275. o25.Name = "Animate"
  276. o25.Parent = o1
  277. table.insert(cors,coroutine.create(function()
  278. wait()
  279. runDummyScript(function()
  280. -- This is in charge of the animations for the character. Pretty much stole it from the default character. Removed emote stuff.
  281. function waitForChild(parent, childName)
  282. local child = parent:findFirstChild(childName)
  283. if child then return child end
  284. while true do
  285. child = parent.ChildAdded:wait()
  286. if child.Name==childName then return child end
  287. end
  288. end
  289.  
  290. local Figure = script.Parent
  291. local Torso = waitForChild(Figure, "Torso")
  292. local RightShoulder = waitForChild(Torso, "Right Shoulder")
  293. local LeftShoulder = waitForChild(Torso, "Left Shoulder")
  294. local RightHip = waitForChild(Torso, "Right Hip")
  295. local LeftHip = waitForChild(Torso, "Left Hip")
  296. local Neck = waitForChild(Torso, "Neck")
  297. local Humanoid = waitForChild(Figure, "Humanoid")
  298. local pose = "Standing"
  299.  
  300. local currentAnim = ""
  301. local currentAnimInstance = nil
  302. local currentAnimTrack = nil
  303. local currentAnimKeyframeHandler = nil
  304. local currentAnimSpeed = 1.0
  305. local animTable = {}
  306. local animNames = {
  307. idle = {
  308. { id = "http://www.roblox.com/asset/?id=180435571", weight = 9 },
  309. { id = "http://www.roblox.com/asset/?id=180435792", weight = 1 }
  310. },
  311. walk = {
  312. { id = "http://www.roblox.com/asset/?id=180426354", weight = 10 }
  313. },
  314. run = {
  315. { id = "run.xml", weight = 10 }
  316. },
  317. jump = {
  318. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  319. },
  320. fall = {
  321. { id = "http://www.roblox.com/asset/?id=180436148", weight = 10 }
  322. },
  323. climb = {
  324. { id = "http://www.roblox.com/asset/?id=180436334", weight = 10 }
  325. },
  326. sit = {
  327. { id = "http://www.roblox.com/asset/?id=178130996", weight = 10 }
  328. },
  329. toolnone = {
  330. { id = "http://www.roblox.com/asset/?id=182393478", weight = 10 }
  331. },
  332. toolslash = {
  333. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  334. -- { id = "slash.xml", weight = 10 }
  335. },
  336. toollunge = {
  337. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  338. },
  339. wave = {
  340. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  341. },
  342. point = {
  343. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  344. },
  345. dance = {
  346. { id = "http://www.roblox.com/asset/?id=182435998", weight = 10 },
  347. { id = "http://www.roblox.com/asset/?id=182491037", weight = 10 },
  348. { id = "http://www.roblox.com/asset/?id=182491065", weight = 10 }
  349. },
  350. dance2 = {
  351. { id = "http://www.roblox.com/asset/?id=182436842", weight = 10 },
  352. { id = "http://www.roblox.com/asset/?id=182491248", weight = 10 },
  353. { id = "http://www.roblox.com/asset/?id=182491277", weight = 10 }
  354. },
  355. dance3 = {
  356. { id = "http://www.roblox.com/asset/?id=182436935", weight = 10 },
  357. { id = "http://www.roblox.com/asset/?id=182491368", weight = 10 },
  358. { id = "http://www.roblox.com/asset/?id=182491423", weight = 10 }
  359. },
  360. laugh = {
  361. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  362. },
  363. cheer = {
  364. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  365. },
  366. }
  367.  
  368. math.randomseed(tick())
  369.  
  370. function configureAnimationSet(name, fileList)
  371. if (animTable[name] ~= nil) then
  372. for _, connection in pairs(animTable[name].connections) do
  373. connection:disconnect()
  374. end
  375. end
  376. animTable[name] = {}
  377. animTable[name].count = 0
  378. animTable[name].totalWeight = 0
  379. animTable[name].connections = {}
  380.  
  381. -- check for config values
  382. local config = script:FindFirstChild(name)
  383. if (config ~= nil) then
  384. -- print("Loading anims " .. name)
  385. table.insert(animTable[name].connections, config.ChildAdded:connect(function(child) configureAnimationSet(name, fileList) end))
  386. table.insert(animTable[name].connections, config.ChildRemoved:connect(function(child) configureAnimationSet(name, fileList) end))
  387. local idx = 1
  388. for _, childPart in pairs(config:GetChildren()) do
  389. if (childPart:IsA("Animation")) then
  390. table.insert(animTable[name].connections, childPart.Changed:connect(function(property) configureAnimationSet(name, fileList) end))
  391. animTable[name][idx] = {}
  392. animTable[name][idx].anim = childPart
  393. local weightObject = childPart:FindFirstChild("Weight")
  394. if (weightObject == nil) then
  395. animTable[name][idx].weight = 1
  396. else
  397. animTable[name][idx].weight = weightObject.Value
  398. end
  399. animTable[name].count = animTable[name].count + 1
  400. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  401. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  402. idx = idx + 1
  403. end
  404. end
  405. end
  406.  
  407. -- fallback to defaults
  408. if (animTable[name].count <= 0) then
  409. for idx, anim in pairs(fileList) do
  410. animTable[name][idx] = {}
  411. animTable[name][idx].anim = Instance.new("Animation")
  412. animTable[name][idx].anim.Name = name
  413. animTable[name][idx].anim.AnimationId = anim.id
  414. animTable[name][idx].weight = anim.weight
  415. animTable[name].count = animTable[name].count + 1
  416. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  417. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  418. end
  419. end
  420. end
  421.  
  422. -- Setup animation objects
  423. function scriptChildModified(child)
  424. local fileList = animNames[child.Name]
  425. if (fileList ~= nil) then
  426. configureAnimationSet(child.Name, fileList)
  427. end
  428. end
  429.  
  430. script.ChildAdded:connect(scriptChildModified)
  431. script.ChildRemoved:connect(scriptChildModified)
  432.  
  433.  
  434. for name, fileList in pairs(animNames) do
  435. configureAnimationSet(name, fileList)
  436. end
  437.  
  438. -- ANIMATION
  439.  
  440. -- declarations
  441. local toolAnim = "None"
  442. local toolAnimTime = 0
  443.  
  444. local jumpAnimTime = 0
  445. local jumpAnimDuration = 0.3
  446.  
  447. local toolTransitionTime = 0.1
  448. local fallTransitionTime = 0.3
  449. local jumpMaxLimbVelocity = 0.75
  450.  
  451. -- functions
  452.  
  453. function stopAllAnimations()
  454. local oldAnim = currentAnim
  455.  
  456. currentAnim = ""
  457. currentAnimInstance = nil
  458. if (currentAnimKeyframeHandler ~= nil) then
  459. currentAnimKeyframeHandler:disconnect()
  460. end
  461.  
  462. if (currentAnimTrack ~= nil) then
  463. currentAnimTrack:Stop()
  464. currentAnimTrack:Destroy()
  465. currentAnimTrack = nil
  466. end
  467. return oldAnim
  468. end
  469.  
  470. function setAnimationSpeed(speed)
  471. if speed ~= currentAnimSpeed then
  472. currentAnimSpeed = speed
  473. currentAnimTrack:AdjustSpeed(currentAnimSpeed)
  474. end
  475. end
  476.  
  477. function keyFrameReachedFunc(frameName)
  478. if (frameName == "End") then
  479. -- print("Keyframe : ".. frameName)
  480.  
  481. local repeatAnim = currentAnim
  482.  
  483. local animSpeed = currentAnimSpeed
  484. playAnimation(repeatAnim, 0.0, Humanoid)
  485. setAnimationSpeed(animSpeed)
  486. end
  487. end
  488.  
  489. -- Preload animations
  490. function playAnimation(animName, transitionTime, humanoid)
  491.  
  492. local roll = math.random(1, animTable[animName].totalWeight)
  493. local origRoll = roll
  494. local idx = 1
  495. while (roll > animTable[animName][idx].weight) do
  496. roll = roll - animTable[animName][idx].weight
  497. idx = idx + 1
  498. end
  499. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  500. local anim = animTable[animName][idx].anim
  501.  
  502. -- switch animation
  503. if (anim ~= currentAnimInstance) then
  504.  
  505. if (currentAnimTrack ~= nil) then
  506. currentAnimTrack:Stop(transitionTime)
  507. currentAnimTrack:Destroy()
  508. end
  509.  
  510. currentAnimSpeed = 1.0
  511.  
  512. -- load it to the humanoid; get AnimationTrack
  513. currentAnimTrack = humanoid:LoadAnimation(anim)
  514.  
  515. -- play the animation
  516. currentAnimTrack:Play(transitionTime)
  517. currentAnim = animName
  518. currentAnimInstance = anim
  519.  
  520. -- set up keyframe name triggers
  521. if (currentAnimKeyframeHandler ~= nil) then
  522. currentAnimKeyframeHandler:disconnect()
  523. end
  524. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  525.  
  526. end
  527.  
  528. end
  529.  
  530. -------------------------------------------------------------------------------------------
  531. -------------------------------------------------------------------------------------------
  532.  
  533. local toolAnimName = ""
  534. local toolAnimTrack = nil
  535. local toolAnimInstance = nil
  536. local currentToolAnimKeyframeHandler = nil
  537.  
  538. function toolKeyFrameReachedFunc(frameName)
  539. if (frameName == "End") then
  540. -- print("Keyframe : ".. frameName)
  541. playToolAnimation(toolAnimName, 0.0, Humanoid)
  542. end
  543. end
  544.  
  545.  
  546. function playToolAnimation(animName, transitionTime, humanoid)
  547.  
  548. local roll = math.random(1, animTable[animName].totalWeight)
  549. local origRoll = roll
  550. local idx = 1
  551. while (roll > animTable[animName][idx].weight) do
  552. roll = roll - animTable[animName][idx].weight
  553. idx = idx + 1
  554. end
  555. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  556. local anim = animTable[animName][idx].anim
  557.  
  558. if (toolAnimInstance ~= anim) then
  559.  
  560. if (toolAnimTrack ~= nil) then
  561. toolAnimTrack:Stop()
  562. toolAnimTrack:Destroy()
  563. transitionTime = 0
  564. end
  565.  
  566. -- load it to the humanoid; get AnimationTrack
  567. toolAnimTrack = humanoid:LoadAnimation(anim)
  568.  
  569. -- play the animation
  570. toolAnimTrack:Play(transitionTime)
  571. toolAnimName = animName
  572. toolAnimInstance = anim
  573.  
  574. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  575. end
  576. end
  577.  
  578. function stopToolAnimations()
  579. local oldAnim = toolAnimName
  580.  
  581. if (currentToolAnimKeyframeHandler ~= nil) then
  582. currentToolAnimKeyframeHandler:disconnect()
  583. end
  584.  
  585. toolAnimName = ""
  586. toolAnimInstance = nil
  587. if (toolAnimTrack ~= nil) then
  588. toolAnimTrack:Stop()
  589. toolAnimTrack:Destroy()
  590. toolAnimTrack = nil
  591. end
  592.  
  593.  
  594. return oldAnim
  595. end
  596.  
  597. -------------------------------------------------------------------------------------------
  598. -------------------------------------------------------------------------------------------
  599.  
  600.  
  601. function onRunning(speed)
  602. if speed>0.01 then
  603. playAnimation("walk", 0.1, Humanoid)
  604. pose = "Running"
  605. else
  606. playAnimation("idle", 0.1, Humanoid)
  607. pose = "Standing"
  608. end
  609. end
  610.  
  611. function onDied()
  612. pose = "Dead"
  613. end
  614.  
  615. function onJumping()
  616. playAnimation("jump", 0.1, Humanoid)
  617. jumpAnimTime = jumpAnimDuration
  618. pose = "Jumping"
  619. end
  620.  
  621. function onClimbing(speed)
  622. playAnimation("climb", 0.1, Humanoid)
  623. setAnimationSpeed(speed / 12.0)
  624. pose = "Climbing"
  625. end
  626.  
  627. function onGettingUp()
  628. pose = "GettingUp"
  629. end
  630.  
  631. function onFreeFall()
  632. if (jumpAnimTime <= 0) then
  633. playAnimation("fall", fallTransitionTime, Humanoid)
  634. end
  635. pose = "FreeFall"
  636. end
  637.  
  638. function onFallingDown()
  639. pose = "FallingDown"
  640. end
  641.  
  642. function onSeated()
  643. pose = "Seated"
  644. end
  645.  
  646. function onPlatformStanding()
  647. pose = "PlatformStanding"
  648. end
  649.  
  650. function onSwimming(speed)
  651. if speed>0 then
  652. pose = "Running"
  653. else
  654. pose = "Standing"
  655. end
  656. end
  657.  
  658. function getTool()
  659. for _, kid in ipairs(Figure:GetChildren()) do
  660. if kid.className == "Tool" then return kid end
  661. end
  662. return nil
  663. end
  664.  
  665. function getToolAnim(tool)
  666. for _, c in ipairs(tool:GetChildren()) do
  667. if c.Name == "toolanim" and c.className == "StringValue" then
  668. return c
  669. end
  670. end
  671. return nil
  672. end
  673.  
  674. function animateTool()
  675.  
  676. if (toolAnim == "None") then
  677. playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  678. return
  679. end
  680.  
  681. if (toolAnim == "Slash") then
  682. playToolAnimation("toolslash", 0, Humanoid)
  683. return
  684. end
  685.  
  686. if (toolAnim == "Lunge") then
  687. playToolAnimation("toollunge", 0, Humanoid)
  688. return
  689. end
  690. end
  691.  
  692. function moveSit()
  693. RightShoulder.MaxVelocity = 0.15
  694. LeftShoulder.MaxVelocity = 0.15
  695. RightShoulder:SetDesiredAngle(3.14 /2)
  696. LeftShoulder:SetDesiredAngle(-3.14 /2)
  697. RightHip:SetDesiredAngle(3.14 /2)
  698. LeftHip:SetDesiredAngle(-3.14 /2)
  699. end
  700.  
  701. local lastTick = 0
  702.  
  703. function move(time)
  704. local amplitude = 1
  705. local frequency = 1
  706. local deltaTime = time - lastTick
  707. lastTick = time
  708.  
  709. local climbFudge = 0
  710. local setAngles = false
  711.  
  712. if (jumpAnimTime > 0) then
  713. jumpAnimTime = jumpAnimTime - deltaTime
  714. end
  715.  
  716. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  717. playAnimation("fall", fallTransitionTime, Humanoid)
  718. elseif (pose == "Seated") then
  719. playAnimation("sit", 0.5, Humanoid)
  720. return
  721. elseif (pose == "Running") then
  722. playAnimation("walk", 0.1, Humanoid)
  723. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  724. -- print("Wha " .. pose)
  725. stopAllAnimations()
  726. amplitude = 0.1
  727. frequency = 1
  728. setAngles = true
  729. end
  730.  
  731. if (setAngles) then
  732. desiredAngle = amplitude * math.sin(time * frequency)
  733.  
  734. RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
  735. LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
  736. RightHip:SetDesiredAngle(-desiredAngle)
  737. LeftHip:SetDesiredAngle(-desiredAngle)
  738. end
  739.  
  740. -- Tool Animation handling
  741. local tool = getTool()
  742. if tool then
  743.  
  744. animStringValueObject = getToolAnim(tool)
  745.  
  746. if animStringValueObject then
  747. toolAnim = animStringValueObject.Value
  748. -- message recieved, delete StringValue
  749. animStringValueObject.Parent = nil
  750. toolAnimTime = time + .3
  751. end
  752.  
  753. if time > toolAnimTime then
  754. toolAnimTime = 0
  755. toolAnim = "None"
  756. end
  757.  
  758. animateTool()
  759. else
  760. stopToolAnimations()
  761. toolAnim = "None"
  762. toolAnimInstance = nil
  763. toolAnimTime = 0
  764. end
  765. end
  766.  
  767. -- connect events
  768. Humanoid.Died:connect(onDied)
  769. Humanoid.Running:connect(onRunning)
  770. Humanoid.Jumping:connect(onJumping)
  771. Humanoid.Climbing:connect(onClimbing)
  772. Humanoid.GettingUp:connect(onGettingUp)
  773. Humanoid.FreeFalling:connect(onFreeFall)
  774. Humanoid.FallingDown:connect(onFallingDown)
  775. Humanoid.Seated:connect(onSeated)
  776. Humanoid.PlatformStanding:connect(onPlatformStanding)
  777. Humanoid.Swimming:connect(onSwimming)
  778.  
  779.  
  780. -- main program
  781.  
  782. local runService = game:service("RunService");
  783.  
  784. -- initialize to idle
  785. playAnimation("idle", 0.1, Humanoid)
  786. pose = "Standing"
  787.  
  788. while Figure.Parent~=nil do
  789. local _, time = wait(0.1)
  790. move(time)
  791. end
  792.  
  793.  
  794.  
  795. end,o25)
  796. end))
  797. o26.Name = "climb"
  798. o26.Parent = o25
  799. o27.Name = "ClimbAnim"
  800. o27.Parent = o26
  801. o27.AnimationId = "http://www.roblox.com/asset/?id=180436334"
  802. o28.Name = "fall"
  803. o28.Parent = o25
  804. o29.Name = "FallAnim"
  805. o29.Parent = o28
  806. o29.AnimationId = "http://www.roblox.com/asset/?id=180436148"
  807. o30.Name = "idle"
  808. o30.Parent = o25
  809. o31.Name = "Animation1"
  810. o31.Parent = o30
  811. o31.AnimationId = "http://www.roblox.com/asset/?id=180435571"
  812. o32.Name = "Weight"
  813. o32.Parent = o31
  814. o32.Value = 9
  815. o33.Name = "Animation2"
  816. o33.Parent = o30
  817. o33.AnimationId = "http://www.roblox.com/asset/?id=180435792"
  818. o34.Name = "Weight"
  819. o34.Parent = o33
  820. o34.Value = 1
  821. o35.Name = "jump"
  822. o35.Parent = o25
  823. o36.Name = "JumpAnim"
  824. o36.Parent = o35
  825. o36.AnimationId = "http://www.roblox.com/asset/?id=125750702"
  826. o37.Name = "run"
  827. o37.Parent = o25
  828. o38.Name = "RunAnim"
  829. o38.Parent = o37
  830. o38.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  831. o39.Name = "sit"
  832. o39.Parent = o25
  833. o40.Name = "SitAnim"
  834. o40.Parent = o39
  835. o40.AnimationId = "http://www.roblox.com/asset/?id=178130996"
  836. o41.Name = "toolnone"
  837. o41.Parent = o25
  838. o42.Name = "ToolNoneAnim"
  839. o42.Parent = o41
  840. o42.AnimationId = "http://www.roblox.com/asset/?id=182393478"
  841. o43.Name = "walk"
  842. o43.Parent = o25
  843. o44.Name = "WalkAnim"
  844. o44.Parent = o43
  845. o44.AnimationId = "http://www.roblox.com/asset/?id=180426354"
  846. o45.Name = "ZombieScript"
  847. o45.Parent = o1
  848. table.insert(cors,coroutine.create(function()
  849. wait()
  850. runDummyScript(function()
  851. --[[
  852. Basic Monster by ArceusInator
  853.  
  854. Information:
  855. Configurations.MaximumDetectionDistance (default 200)
  856. The monster will not detect players past this point. If you set it to a negative number then the monster will be able to chase from any distance.
  857.  
  858. Configurations.CanGiveUp (default true)
  859. If true, the monster will give up if its target goes past the MaximumDetectionDistance. This is a pretty good idea if you have people teleporting around.
  860.  
  861. Configurations.CanRespawn (default true)
  862. If true, the monster will respawn after it dies
  863.  
  864. Configurations.AutoDetectSpawnPoint (default true)
  865. If true, the spawn point will be auto detected based on where the monster is when it starts
  866.  
  867. Configurations.SpawnPoint (default 0,0,0)
  868. If Settings.AutoDetectSpawnPoint is disabled, this will be set to the monster's initial position. This value will be used when the monster auto respawns to tell it where to spawn next.
  869.  
  870. Configurations.FriendlyTeam (default Really black)
  871. The monster will not attack players on this team
  872.  
  873.  
  874.  
  875. Mind.CurrentTargetHumanoid (Humanoid objects only)
  876. You can force the monster to follow a certain humanoid by setting this to that humanoid
  877.  
  878.  
  879.  
  880. Monster.Respawn (Function)
  881. Arguments are: Vector3 point
  882. Info: Respawns the monster at the given point, or at the SpawnPoint setting if none if provided
  883.  
  884. Monster.Died (Event)
  885. Info: Fired when the monster dies
  886.  
  887. Monster.Respawned (Event)
  888. Info: Fired when the monster respawns
  889. --]]
  890.  
  891. local Self = script.Parent
  892. local Settings = Self:FindFirstChild'Configurations' -- Points to the settings.
  893. local Mind = Self:FindFirstChild'Mind' -- Points to the monster's mind. You can edit parts of this from other scripts in-game to change the monster's behavior. Advanced users only.
  894.  
  895. --
  896. -- Verify that everything is where it should be
  897. assert(Self:FindFirstChild'Humanoid' ~= nil, 'Monster does not have a humanoid')
  898. assert(Settings ~= nil, 'Monster does not have a Configurations object')
  899. assert(Settings:FindFirstChild'MaximumDetectionDistance' ~= nil and Settings.MaximumDetectionDistance:IsA'NumberValue', 'Monster does not have a MaximumDetectionDistance (NumberValue) setting')
  900. assert(Settings:FindFirstChild'CanGiveUp' ~= nil and Settings.CanGiveUp:IsA'BoolValue', 'Monster does not have a CanGiveUp (BoolValue) setting')
  901. assert(Settings:FindFirstChild'CanRespawn' ~= nil and Settings.CanRespawn:IsA'BoolValue', 'Monster does not have a CanRespawn (BoolValue) setting')
  902. assert(Settings:FindFirstChild'SpawnPoint' ~= nil and Settings.SpawnPoint:IsA'Vector3Value', 'Monster does not have a SpawnPoint (Vector3Value) setting')
  903. assert(Settings:FindFirstChild'AutoDetectSpawnPoint' ~= nil and Settings.AutoDetectSpawnPoint:IsA'BoolValue', 'Monster does not have a AutoDetectSpawnPoint (BoolValue) setting')
  904. assert(Settings:FindFirstChild'FriendlyTeam' ~= nil and Settings.FriendlyTeam:IsA'BrickColorValue', 'Monster does not have a FriendlyTeam (BrickColorValue) setting')
  905. assert(Settings:FindFirstChild'AttackDamage' ~= nil and Settings.AttackDamage:IsA'NumberValue', 'Monster does not have a AttackDamage (NumberValue) setting')
  906. assert(Settings:FindFirstChild'AttackFrequency' ~= nil and Settings.AttackFrequency:IsA'NumberValue', 'Monster does not have a AttackFrequency (NumberValue) setting')
  907. assert(Settings:FindFirstChild'AttackRange' ~= nil and Settings.AttackRange:IsA'NumberValue', 'Monster does not have a AttackRange (NumberValue) setting')
  908. assert(Mind ~= nil, 'Monster does not have a Mind object')
  909. assert(Mind:FindFirstChild'CurrentTargetHumanoid' ~= nil and Mind.CurrentTargetHumanoid:IsA'ObjectValue', 'Monster does not have a CurrentTargetHumanoid (ObjectValue) mind setting')
  910. assert(Self:FindFirstChild'Respawn' and Self.Respawn:IsA'BindableFunction', 'Monster does not have a Respawn BindableFunction')
  911. assert(Self:FindFirstChild'Died' and Self.Died:IsA'BindableEvent', 'Monster does not have a Died BindableEvent')
  912. assert(Self:FindFirstChild'Respawned' and Self.Died:IsA'BindableEvent', 'Monster does not have a Respawned BindableEvent')
  913. assert(Self:FindFirstChild'Attacked' and Self.Died:IsA'BindableEvent', 'Monster does not have a Attacked BindableEvent')
  914. assert(script:FindFirstChild'Attack' and script.Attack:IsA'Animation', 'Monster does not have a MonsterScript.Attack Animation')
  915.  
  916.  
  917. --
  918. --
  919. local Info = {
  920. -- These are constant values. Don't change them unless you know what you're doing.
  921.  
  922. -- Services
  923. Players = Game:GetService 'Players',
  924. PathfindingService = Game:GetService 'PathfindingService',
  925.  
  926. -- Advanced settings
  927. RecomputePathFrequency = 1, -- The monster will recompute its path this many times per second
  928. RespawnWaitTime = 5, -- How long to wait before the monster respawns
  929. JumpCheckFrequency = 1, -- How many times per second it will do a jump check
  930. }
  931. local Data = {
  932. -- These are variable values used internally by the script. Advanced users only.
  933.  
  934. LastRecomputePath = 0,
  935. Recomputing = false, -- Reocmputing occurs async, meaning this script will still run while it's happening. This variable will prevent the script from running two recomputes at once.
  936. PathCoords = {},
  937. IsDead = false,
  938. TimeOfDeath = 0,
  939. CurrentNode = nil,
  940. CurrentNodeIndex = 1,
  941. AutoRecompute = true,
  942. LastJumpCheck = 0,
  943. LastAttack = 0,
  944.  
  945. BaseMonster = Self:Clone(),
  946. AttackTrack = nil,
  947. }
  948.  
  949. --
  950. --
  951. local Monster = {} -- Create the monster class
  952.  
  953.  
  954. function Monster:GetCFrame()
  955. -- Returns the CFrame of the monster's humanoidrootpart
  956.  
  957. local humanoidRootPart = Self:FindFirstChild('HumanoidRootPart')
  958.  
  959. if humanoidRootPart ~= nil and humanoidRootPart:IsA('BasePart') then
  960. return humanoidRootPart.CFrame
  961. else
  962. return CFrame.new()
  963. end
  964. end
  965.  
  966. function Monster:GetMaximumDetectionDistance()
  967. -- Returns the maximum detection distance
  968.  
  969. local setting = Settings.MaximumDetectionDistance.Value
  970.  
  971. if setting < 0 then
  972. return math.huge
  973. else
  974. return setting
  975. end
  976. end
  977.  
  978. function Monster:SearchForTarget()
  979. -- Finds the closest player and sets the target
  980.  
  981. local players = Info.Players:GetPlayers()
  982. local closestCharacter, closestCharacterDistance
  983.  
  984. for i=1, #players do
  985. local player = players[i]
  986.  
  987. if player.Neutral or player.TeamColor ~= Settings.FriendlyTeam.Value then
  988. local character = player.Character
  989.  
  990. if character ~= nil and character:FindFirstChild('Humanoid') ~= nil and character.Humanoid:IsA('Humanoid') then
  991. local distance = player:DistanceFromCharacter(Monster:GetCFrame().p)
  992.  
  993. if distance < Monster:GetMaximumDetectionDistance() then
  994. if closestCharacter == nil then
  995. closestCharacter, closestCharacterDistance = character, distance
  996. else
  997. if closestCharacterDistance > distance then
  998. closestCharacter, closestCharacterDistance = character, distance
  999. end
  1000. end
  1001. end
  1002. end
  1003. end
  1004. end
  1005.  
  1006.  
  1007. if closestCharacter ~= nil then
  1008. Mind.CurrentTargetHumanoid.Value = closestCharacter.Humanoid
  1009. end
  1010. end
  1011.  
  1012. function Monster:TryRecomputePath()
  1013. if Data.AutoRecompute or tick() - Data.LastRecomputePath > 1/Info.RecomputePathFrequency then
  1014. Monster:RecomputePath()
  1015. end
  1016. end
  1017.  
  1018. function Monster:GetTargetCFrame()
  1019. local targetHumanoid = Mind.CurrentTargetHumanoid.Value
  1020.  
  1021. if Monster:TargetIsValid() then
  1022. return targetHumanoid.Torso.CFrame
  1023. else
  1024. return CFrame.new()
  1025. end
  1026. end
  1027.  
  1028. function Monster:IsAlive()
  1029. return Self.Humanoid.Health > 0 and Self.Humanoid.Torso ~= nil
  1030. end
  1031.  
  1032. function Monster:TargetIsValid()
  1033. local targetHumanoid = Mind.CurrentTargetHumanoid.Value
  1034.  
  1035. if targetHumanoid ~= nil and targetHumanoid:IsA 'Humanoid' and targetHumanoid.Torso ~= nil and targetHumanoid.Torso:IsA 'BasePart' then
  1036. return true
  1037. else
  1038. return false
  1039. end
  1040. end
  1041.  
  1042. function Monster:HasClearLineOfSight()
  1043. -- Going to cast a ray to see if I can just see my target
  1044. local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p
  1045.  
  1046. local hit, pos = Workspace:FindPartOnRayWithIgnoreList(
  1047. Ray.new(
  1048. myPos,
  1049. targetPos - myPos
  1050. ),
  1051. {
  1052. Self,
  1053. Mind.CurrentTargetHumanoid.Value.Parent
  1054. }
  1055. )
  1056.  
  1057.  
  1058. if hit == nil then
  1059. return true
  1060. else
  1061. return false
  1062. end
  1063. end
  1064.  
  1065. function Monster:RecomputePath()
  1066. if not Data.Recomputing then
  1067. if Monster:IsAlive() and Monster:TargetIsValid() then
  1068. if Monster:HasClearLineOfSight() then
  1069. Data.AutoRecompute = true
  1070. Data.PathCoords = {
  1071. Monster:GetCFrame().p,
  1072. Monster:GetTargetCFrame().p
  1073. }
  1074.  
  1075. Data.LastRecomputePath = tick()
  1076. Data.CurrentNode = nil
  1077. Data.CurrentNodeIndex = 2 -- Starts chasing the target without evaluating its current position
  1078. else
  1079. -- Do pathfinding since you can't walk straight
  1080. Data.Recomputing = true -- Basically a debounce.
  1081. Data.AutoRecompute = false
  1082.  
  1083.  
  1084. local path = Info.PathfindingService:ComputeSmoothPathAsync(
  1085. Monster:GetCFrame().p,
  1086. Monster:GetTargetCFrame().p,
  1087. 500
  1088. )
  1089. Data.PathCoords = path:GetPointCoordinates()
  1090.  
  1091.  
  1092. Data.Recomputing = false
  1093. Data.LastRecomputePath = tick()
  1094. Data.CurrentNode = nil
  1095. Data.CurrentNodeIndex = 1
  1096. end
  1097. end
  1098. end
  1099. end
  1100.  
  1101. function Monster:Update()
  1102. Monster:ReevaluateTarget()
  1103. Monster:SearchForTarget()
  1104. Monster:TryRecomputePath()
  1105. Monster:TravelPath()
  1106. end
  1107.  
  1108. function Monster:TravelPath()
  1109. local closest, closestDistance, closestIndex
  1110. local myPosition = Monster:GetCFrame().p
  1111. local skipCurrentNode = Data.CurrentNode ~= nil and (Data.CurrentNode - myPosition).magnitude < 3
  1112.  
  1113. for i=Data.CurrentNodeIndex, #Data.PathCoords do
  1114. local coord = Data.PathCoords[i]
  1115. if not (skipCurrentNode and coord == Data.CurrentNode) then
  1116. local distance = (coord - myPosition).magnitude
  1117.  
  1118. if closest == nil then
  1119. closest, closestDistance, closestIndex = coord, distance, i
  1120. else
  1121. if distance < closestDistance then
  1122. closest, closestDistance, closestIndex = coord, distance, i
  1123. else
  1124. break
  1125. end
  1126. end
  1127. end
  1128. end
  1129.  
  1130.  
  1131. --
  1132. if closest ~= nil then
  1133. Data.CurrentNode = closest
  1134. Data.CurrentNodeIndex = closestIndex
  1135.  
  1136. local humanoid = Self:FindFirstChild 'Humanoid'
  1137.  
  1138. if humanoid ~= nil and humanoid:IsA'Humanoid' then
  1139. humanoid:MoveTo(closest)
  1140. end
  1141.  
  1142. if Monster:IsAlive() and Monster:TargetIsValid() then
  1143. Monster:TryJumpCheck()
  1144. Monster:TryAttack()
  1145. end
  1146.  
  1147. if closestIndex == #Data.PathCoords then
  1148. -- Reached the end of the path, force a new check
  1149. Data.AutoRecompute = true
  1150. end
  1151. end
  1152. end
  1153.  
  1154. function Monster:TryJumpCheck()
  1155. if tick() - Data.LastJumpCheck > 1/Info.JumpCheckFrequency then
  1156. Monster:JumpCheck()
  1157. end
  1158. end
  1159.  
  1160. function Monster:TryAttack()
  1161. if tick() - Data.LastAttack > 1/Settings.AttackFrequency.Value then
  1162. Monster:Attack()
  1163. end
  1164. end
  1165.  
  1166. function Monster:Attack()
  1167. local myPos, targetPos = Monster:GetCFrame().p, Monster:GetTargetCFrame().p
  1168.  
  1169. if (myPos - targetPos).magnitude <= Settings.AttackRange.Value then
  1170. Mind.CurrentTargetHumanoid.Value:TakeDamage(Settings.AttackDamage.Value)
  1171. Data.LastAttack = tick()
  1172. Data.AttackTrack:Play()
  1173. end
  1174. end
  1175.  
  1176. function Monster:JumpCheck()
  1177. -- Do a raycast to check if we need to jump
  1178. local myCFrame = Monster:GetCFrame()
  1179. local checkVector = (Monster:GetTargetCFrame().p - myCFrame.p).unit*2
  1180.  
  1181. local hit, pos = Workspace:FindPartOnRay(
  1182. Ray.new(
  1183. myCFrame.p + Vector3.new(0, -2.4, 0),
  1184. checkVector
  1185. ),
  1186. Self
  1187. )
  1188.  
  1189. if hit ~= nil and not hit:IsDescendantOf(Mind.CurrentTargetHumanoid.Value.Parent) then
  1190. -- Do a slope check to make sure we're not walking up a ramp
  1191.  
  1192. local hit2, pos2 = Workspace:FindPartOnRay(
  1193. Ray.new(
  1194. myCFrame.p + Vector3.new(0, -2.3, 0),
  1195. checkVector
  1196. ),
  1197. Self
  1198. )
  1199.  
  1200. if hit2 == hit then
  1201. if ((pos2 - pos)*Vector3.new(1,0,1)).magnitude < 0.05 then -- Will pass for any ramp with <2 slope
  1202. Self.Humanoid.Jump = true
  1203. end
  1204. end
  1205. end
  1206.  
  1207. Data.LastJumpCheck = tick()
  1208. end
  1209.  
  1210. function Monster:Connect()
  1211. Mind.CurrentTargetHumanoid.Changed:connect(function(humanoid)
  1212. if humanoid ~= nil then
  1213. assert(humanoid:IsA'Humanoid', 'Monster target must be a humanoid')
  1214.  
  1215. Monster:RecomputePath()
  1216. end
  1217. end)
  1218.  
  1219. Self.Respawn.OnInvoke = function(point)
  1220. Monster:Respawn(point)
  1221. end
  1222. end
  1223.  
  1224. function Monster:Initialize()
  1225. Monster:Connect()
  1226.  
  1227. if Settings.AutoDetectSpawnPoint.Value then
  1228. Settings.SpawnPoint.Value = Monster:GetCFrame().p
  1229. end
  1230. end
  1231.  
  1232. function Monster:Respawn(point)
  1233. local point = point or Settings.SpawnPoint.Value
  1234.  
  1235. for index, obj in next, Data.BaseMonster:Clone():GetChildren() do
  1236. if obj.Name == 'Configurations' or obj.Name == 'Mind' or obj.Name == 'Respawned' or obj.Name == 'Died' or obj.Name == 'MonsterScript' or obj.Name == 'Respawn' then
  1237. obj:Destroy()
  1238. else
  1239. Self[obj.Name]:Destroy()
  1240. obj.Parent = Self
  1241. end
  1242. end
  1243.  
  1244. Monster:InitializeUnique()
  1245.  
  1246. Self.Parent = Workspace
  1247.  
  1248. Self.HumanoidRootPart.CFrame = CFrame.new(point)
  1249. Settings.SpawnPoint.Value = point
  1250. Self.Respawned:Fire()
  1251. end
  1252.  
  1253. function Monster:InitializeUnique()
  1254. Data.AttackTrack = Self.Humanoid:LoadAnimation(script.Attack)
  1255. end
  1256.  
  1257. function Monster:ReevaluateTarget()
  1258. local currentTarget = Mind.CurrentTargetHumanoid.Value
  1259.  
  1260. if currentTarget ~= nil and currentTarget:IsA'Humanoid' then
  1261. local character = currentTarget.Parent
  1262.  
  1263. if character ~= nil then
  1264. local player = Info.Players:GetPlayerFromCharacter(character)
  1265.  
  1266. if player ~= nil then
  1267. if not player.Neutral and player.TeamColor == Settings.FriendlyTeam.Value then
  1268. Mind.CurrentTargetHumanoid.Value = nil
  1269. end
  1270. end
  1271. end
  1272.  
  1273.  
  1274. if currentTarget == Mind.CurrentTargetHumanoid.Value then
  1275. local torso = currentTarget.Torso
  1276.  
  1277. if torso ~= nil and torso:IsA 'BasePart' then
  1278. if Settings.CanGiveUp.Value and (torso.Position - Monster:GetCFrame().p).magnitude > Monster:GetMaximumDetectionDistance() then
  1279. Mind.CurrentTargetHumanoid.Value = nil
  1280. end
  1281. end
  1282. end
  1283. end
  1284. end
  1285.  
  1286. --
  1287. --
  1288. Monster:Initialize()
  1289. Monster:InitializeUnique()
  1290.  
  1291. while true do
  1292. if not Monster:IsAlive() then
  1293. if Data.IsDead == false then
  1294. Data.IsDead = true
  1295. Data.TimeOfDeath = tick()
  1296. Self.Died:Fire()
  1297. end
  1298. if Data.IsDead == true then
  1299. if tick()-Data.TimeOfDeath > Info.RespawnWaitTime then
  1300. Monster:Respawn()
  1301. end
  1302. end
  1303. end
  1304.  
  1305. if Monster:IsAlive() then
  1306. Monster:Update()
  1307. end
  1308.  
  1309. wait()
  1310. end
  1311. end,o45)
  1312. end))
  1313. o46.Name = "Attack"
  1314. o46.Parent = o45
  1315. o46.AnimationId = "rbxassetid://105211514"
  1316. o47.Name = "Configurations"
  1317. o47.Parent = o1
  1318. o48.Name = "MaximumDetectionDistance"
  1319. o48.Parent = o47
  1320. o48.Value = 200
  1321. o49.Name = "CanGiveUp"
  1322. o49.Parent = o47
  1323. o49.Value = true
  1324. o50.Name = "CanRespawn"
  1325. o50.Parent = o47
  1326. o50.Value = true
  1327. o51.Name = "SpawnPoint"
  1328. o51.Parent = o47
  1329. o52.Name = "AutoDetectSpawnPoint"
  1330. o52.Parent = o47
  1331. o52.Value = true
  1332. o53.Name = "FriendlyTeam"
  1333. o53.Parent = o47
  1334. o53.Value = BrickColor.new("Really black")
  1335. o54.Name = "AttackDamage"
  1336. o54.Parent = o47
  1337. o54.Value = 9999999999
  1338. o55.Name = "AttackFrequency"
  1339. o55.Parent = o47
  1340. o55.Value = 2
  1341. o56.Name = "AttackRange"
  1342. o56.Parent = o47
  1343. o56.Value = 3
  1344. o57.Name = "Mind"
  1345. o57.Parent = o1
  1346. o58.Name = "CurrentTargetHumanoid"
  1347. o58.Parent = o57
  1348. o59.Name = "Died"
  1349. o59.Parent = o1
  1350. o60.Name = "Respawn"
  1351. o60.Parent = o1
  1352. o61.Name = "Respawned"
  1353. o61.Parent = o1
  1354. o62.Parent = o1
  1355. mas.Parent = workspace
  1356. mas:MakeJoints()
  1357. local mas1 = mas:GetChildren()
  1358. for i=1,#mas1 do
  1359. mas1[i].Parent = workspace
  1360. ypcall(function() mas1[i]:MakeJoints() end)
  1361. end
  1362. mas:Destroy()
  1363. for i=1,#cors do
  1364. coroutine.resume(cors[i])
  1365. end
  1366.  
  1367. game:GetService("Lighting").Ambient = Color3.new(0.498039, 0.498039, 0.498039)
  1368. game:GetService("Lighting").Brightness = 5
  1369. game:GetService("Lighting").ColorShift_Bottom = Color3.new(1, 1, 1)
  1370. game:GetService("Lighting").ColorShift_Top = Color3.new(1, 1, 1)
  1371. game:GetService("Lighting").GlobalShadows = true
  1372. game:GetService("Lighting").OutdoorAmbient = Color3.new(0.631373, 0.631373, 0.631373)
  1373. game:GetService("Lighting").Outlines = false
  1374. game:GetService("Lighting").GeographicLatitude = 41.733299255371
  1375. game:GetService("Lighting").TimeOfDay = "16:00:00"
  1376. game:GetService("Lighting").FogColor = Color3.new(0, -7.50588, 0)
  1377. game:GetService("Lighting").FogEnd = 1.0000000037683e+14
  1378. game:GetService("Lighting").FogStart = 0
Advertisement
Add Comment
Please, Sign In to add comment