Advertisement
firebudgy

Untitled

Feb 3rd, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.46 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Model0 = Instance.new("Model")
  20. Part1 = Instance.new("Part")
  21. SpecialMesh2 = Instance.new("SpecialMesh")
  22. Sound3 = Instance.new("Sound")
  23. Sound4 = Instance.new("Sound")
  24. Decal5 = Instance.new("Decal")
  25. Weld6 = Instance.new("Weld")
  26. Weld7 = Instance.new("Weld")
  27. Part8 = Instance.new("Part")
  28. Motor6D9 = Instance.new("Motor6D")
  29. Motor6D10 = Instance.new("Motor6D")
  30. Motor6D11 = Instance.new("Motor6D")
  31. Weld12 = Instance.new("Weld")
  32. Weld13 = Instance.new("Weld")
  33. Part14 = Instance.new("Part")
  34. Part15 = Instance.new("Part")
  35. Weld16 = Instance.new("Weld")
  36. Part17 = Instance.new("Part")
  37. Part18 = Instance.new("Part")
  38. Part19 = Instance.new("Part")
  39. Motor6D20 = Instance.new("Motor6D")
  40. Script21 = Instance.new("Script")
  41. StringValue22 = Instance.new("StringValue")
  42. Animation23 = Instance.new("Animation")
  43. StringValue24 = Instance.new("StringValue")
  44. Animation25 = Instance.new("Animation")
  45. StringValue26 = Instance.new("StringValue")
  46. Animation27 = Instance.new("Animation")
  47. NumberValue28 = Instance.new("NumberValue")
  48. Animation29 = Instance.new("Animation")
  49. NumberValue30 = Instance.new("NumberValue")
  50. StringValue31 = Instance.new("StringValue")
  51. Animation32 = Instance.new("Animation")
  52. StringValue33 = Instance.new("StringValue")
  53. Animation34 = Instance.new("Animation")
  54. StringValue35 = Instance.new("StringValue")
  55. Animation36 = Instance.new("Animation")
  56. StringValue37 = Instance.new("StringValue")
  57. Animation38 = Instance.new("Animation")
  58. Script39 = Instance.new("Script")
  59. Shirt40 = Instance.new("Shirt")
  60. Pants41 = Instance.new("Pants")
  61. Hat42 = Instance.new("Hat")
  62. Part43 = Instance.new("Part")
  63. SpecialMesh44 = Instance.new("SpecialMesh")
  64. Part45 = Instance.new("Part")
  65. Sound46 = Instance.new("Sound")
  66. Sound47 = Instance.new("Sound")
  67. Part48 = Instance.new("Part")
  68. SpecialMesh49 = Instance.new("SpecialMesh")
  69. Script50 = Instance.new("Script")
  70. Humanoid51 = Instance.new("Humanoid")
  71. Hat52 = Instance.new("Hat")
  72. Part53 = Instance.new("Part")
  73. SpecialMesh54 = Instance.new("SpecialMesh")
  74. Model0.Name = "Cleanup Crew"
  75. Model0.Parent = mas
  76. Model0.PrimaryPart = Part1
  77. Part1.Name = "Head"
  78. Part1.Parent = Model0
  79. Part1.BrickColor = BrickColor.new("Pastel brown")
  80. Part1.Rotation = Vector3.new(0, -90, 0)
  81. Part1.FormFactor = Enum.FormFactor.Symmetric
  82. Part1.Size = Vector3.new(2, 1, 1)
  83. Part1.CFrame = CFrame.new(12.4519968, 4.5, 63.8128319, -5.73683906e-07, -9.13071307e-09, -1, 7.667877e-09, 1, -9.13071752e-09, 1, -7.66788233e-09, -5.73683906e-07)
  84. Part1.TopSurface = Enum.SurfaceType.Smooth
  85. Part1.Color = Color3.new(1, 0.8, 0.6)
  86. Part1.Position = Vector3.new(12.4519968, 4.5, 63.8128319)
  87. Part1.Orientation = Vector3.new(0, -90, 0)
  88. Part1.Color = Color3.new(1, 0.8, 0.6)
  89. SpecialMesh2.Parent = Part1
  90. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  91. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  92. Sound3.Name = "Die"
  93. Sound3.Parent = Part1
  94. Sound3.Pitch = 1.1000000238419
  95. Sound3.SoundId = "rbxassetid://657622857"
  96. Sound3.Volume = 1
  97. Sound4.Name = "SeeEnemy"
  98. Sound4.Parent = Part1
  99. Sound4.SoundId = "rbxassetid://657622327"
  100. Sound4.Volume = 1
  101. Decal5.Parent = Part1
  102. Decal5.Texture = "http://www.roblox.com/asset/?id=41675658"
  103. Weld6.Name = "HeadWeld"
  104. Weld6.Parent = Part1
  105. Weld6.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  106. Weld6.C1 = CFrame.new(0, -0.100000001, -0.0700000003, 1, 0, -0, 0, 0.980580688, 0.196116135, 0, -0.196116135, 0.980580688)
  107. Weld6.Part0 = Part1
  108. Weld6.Part1 = Part43
  109. Weld7.Name = "HeadWeld"
  110. Weld7.Parent = Part1
  111. Weld7.C0 = CFrame.new(0, 0.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  112. Weld7.C1 = CFrame.new(0, -0.100000001, -0.0700000003, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  113. Weld7.Part0 = Part1
  114. Weld7.Part1 = Part53
  115. Part8.Name = "Torso"
  116. Part8.Parent = Model0
  117. Part8.BrickColor = BrickColor.new("Institutional white")
  118. Part8.Rotation = Vector3.new(0, -90, 0)
  119. Part8.FormFactor = Enum.FormFactor.Symmetric
  120. Part8.Size = Vector3.new(2, 2, 1)
  121. Part8.CFrame = CFrame.new(12.4519968, 2.99999976, 63.8128319, -5.73683906e-07, -9.13071307e-09, -1, 7.667877e-09, 1, -9.13071752e-09, 1, -7.66788233e-09, -5.73683906e-07)
  122. Part8.LeftSurface = Enum.SurfaceType.Weld
  123. Part8.RightSurface = Enum.SurfaceType.Weld
  124. Part8.Color = Color3.new(0.972549, 0.972549, 0.972549)
  125. Part8.Position = Vector3.new(12.4519968, 2.99999976, 63.8128319)
  126. Part8.Orientation = Vector3.new(0, -90, 0)
  127. Part8.Color = Color3.new(0.972549, 0.972549, 0.972549)
  128. Motor6D9.Name = "Right Hip"
  129. Motor6D9.Parent = Part8
  130. Motor6D9.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  131. Motor6D9.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  132. Motor6D9.Part0 = Part8
  133. Motor6D9.Part1 = Part18
  134. Motor6D9.MaxVelocity = 0.10000000149012
  135. Motor6D10.Name = "Left Hip"
  136. Motor6D10.Parent = Part8
  137. Motor6D10.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  138. Motor6D10.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  139. Motor6D10.Part0 = Part8
  140. Motor6D10.Part1 = Part17
  141. Motor6D10.MaxVelocity = 0.10000000149012
  142. Motor6D11.Name = "Neck"
  143. Motor6D11.Parent = Part8
  144. Motor6D11.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  145. Motor6D11.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  146. Motor6D11.Part0 = Part8
  147. Motor6D11.Part1 = Part1
  148. Motor6D11.MaxVelocity = 0.10000000149012
  149. Weld12.Parent = Part8
  150. Weld12.C1 = CFrame.new(-1.20000005, 0.5, 0.400000006, 0.99619472, 0, -0.087155737, 0.087155737, 1.19248806e-08, 0.99619472, 1.03932174e-09, -1, 1.18795027e-08)
  151. Weld12.Part0 = Part8
  152. Weld12.Part1 = Part15
  153. Weld13.Parent = Part8
  154. Weld13.C1 = CFrame.new(0.800000012, 0.5, 0.400000006, 0.766044438, 0, 0.642787576, -0.642787576, 1.19248806e-08, 0.766044438, -7.66516539e-09, -1, 9.13498877e-09)
  155. Weld13.Part0 = Part8
  156. Weld13.Part1 = Part14
  157. Part14.Name = "Left Arm"
  158. Part14.Parent = Model0
  159. Part14.BrickColor = BrickColor.new("Pastel brown")
  160. Part14.Rotation = Vector3.new(90, 0, 130)
  161. Part14.CanCollide = false
  162. Part14.FormFactor = Enum.FormFactor.Symmetric
  163. Part14.Size = Vector3.new(1, 2, 1)
  164. Part14.CFrame = CFrame.new(13.3492489, 3.39999986, 63.521389, -0.642787993, -0.76604408, -4.27125002e-12, 4.82280882e-12, 1.52944324e-12, -1, 0.76604408, -0.642787993, 2.71169719e-12)
  165. Part14.Color = Color3.new(1, 0.8, 0.6)
  166. Part14.Position = Vector3.new(13.3492489, 3.39999986, 63.521389)
  167. Part14.Orientation = Vector3.new(90, -130, 0)
  168. Part14.Color = Color3.new(1, 0.8, 0.6)
  169. Part15.Name = "Right Arm"
  170. Part15.Parent = Model0
  171. Part15.BrickColor = BrickColor.new("Pastel brown")
  172. Part15.Rotation = Vector3.new(90, 0, 85)
  173. Part15.CanCollide = false
  174. Part15.FormFactor = Enum.FormFactor.Symmetric
  175. Part15.Size = Vector3.new(1, 2, 1)
  176. Part15.CFrame = CFrame.new(13.0546808, 3.39999986, 64.9646912, 0.0871551633, -0.99619478, -2.74879053e-09, 8.4344931e-09, 3.49720697e-09, -1, 0.99619478, 0.0871551633, 8.70719674e-09)
  177. Part15.Color = Color3.new(1, 0.8, 0.6)
  178. Part15.Position = Vector3.new(13.0546808, 3.39999986, 64.9646912)
  179. Part15.Orientation = Vector3.new(90, -85, 0)
  180. Part15.Color = Color3.new(1, 0.8, 0.6)
  181. Weld16.Name = "RightGrip"
  182. Weld16.Parent = Part15
  183. Weld16.C0 = CFrame.new(0, -1, 0, 1, 0, -0, 0, 0, 1, 0, -1, 0)
  184. Weld16.C1 = CFrame.new(0, -0.200000003, 0.200000003, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  185. Weld16.Part0 = Part15
  186. Weld16.Part1 = Part45
  187. Part17.Name = "Left Leg"
  188. Part17.Parent = Model0
  189. Part17.BrickColor = BrickColor.new("Institutional white")
  190. Part17.Rotation = Vector3.new(0, -90, 0)
  191. Part17.CanCollide = false
  192. Part17.FormFactor = Enum.FormFactor.Symmetric
  193. Part17.Size = Vector3.new(1, 2, 1)
  194. Part17.CFrame = CFrame.new(12.4519968, 0.999999762, 63.3128319, -5.73683906e-07, -9.13071307e-09, -1, 7.667877e-09, 1, -9.13071752e-09, 1, -7.66788233e-09, -5.73683906e-07)
  195. Part17.BottomSurface = Enum.SurfaceType.Smooth
  196. Part17.Color = Color3.new(0.972549, 0.972549, 0.972549)
  197. Part17.Position = Vector3.new(12.4519968, 0.999999762, 63.3128319)
  198. Part17.Orientation = Vector3.new(0, -90, 0)
  199. Part17.Color = Color3.new(0.972549, 0.972549, 0.972549)
  200. Part18.Name = "Right Leg"
  201. Part18.Parent = Model0
  202. Part18.BrickColor = BrickColor.new("Institutional white")
  203. Part18.Rotation = Vector3.new(0, -90, 0)
  204. Part18.CanCollide = false
  205. Part18.FormFactor = Enum.FormFactor.Symmetric
  206. Part18.Size = Vector3.new(1, 2, 1)
  207. Part18.CFrame = CFrame.new(12.4519968, 0.999999762, 64.3128357, -5.73683906e-07, -9.13071307e-09, -1, 7.667877e-09, 1, -9.13071752e-09, 1, -7.66788233e-09, -5.73683906e-07)
  208. Part18.BottomSurface = Enum.SurfaceType.Smooth
  209. Part18.Color = Color3.new(0.972549, 0.972549, 0.972549)
  210. Part18.Position = Vector3.new(12.4519968, 0.999999762, 64.3128357)
  211. Part18.Orientation = Vector3.new(0, -90, 0)
  212. Part18.Color = Color3.new(0.972549, 0.972549, 0.972549)
  213. Part19.Name = "HumanoidRootPart"
  214. Part19.Parent = Model0
  215. Part19.BrickColor = BrickColor.new("Bright blue")
  216. Part19.Transparency = 1
  217. Part19.Rotation = Vector3.new(0, -90, 0)
  218. Part19.FormFactor = Enum.FormFactor.Symmetric
  219. Part19.Size = Vector3.new(2, 2, 1)
  220. Part19.CFrame = CFrame.new(12.4519968, 2.99999976, 63.8128319, -5.73683906e-07, -9.13071307e-09, -1, 7.667877e-09, 1, -9.13071752e-09, 1, -7.66788233e-09, -5.73683906e-07)
  221. Part19.BottomSurface = Enum.SurfaceType.Smooth
  222. Part19.TopSurface = Enum.SurfaceType.Smooth
  223. Part19.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  224. Part19.Position = Vector3.new(12.4519968, 2.99999976, 63.8128319)
  225. Part19.Orientation = Vector3.new(0, -90, 0)
  226. Part19.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  227. Motor6D20.Name = "RootJoint"
  228. Motor6D20.Parent = Part19
  229. Motor6D20.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  230. Motor6D20.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  231. Motor6D20.Part0 = Part19
  232. Motor6D20.Part1 = Part8
  233. Motor6D20.MaxVelocity = 0.10000000149012
  234. Script21.Name = "Animate"
  235. Script21.Parent = Model0
  236. table.insert(cors,sandbox(Script21,function()
  237. wait(5)
  238. function waitForChild(parent, childName)
  239. local child = parent:findFirstChild(childName)
  240. if child then return child end
  241. while true do
  242. child = parent.ChildAdded:wait()
  243. if child.Name==childName then return child end
  244. end
  245. end
  246.  
  247. local Figure = script.Parent
  248. local Torso = waitForChild(Figure, "Torso")
  249. local RightHip = waitForChild(Torso, "Right Hip")
  250. local LeftHip = waitForChild(Torso, "Left Hip")
  251. local Neck = waitForChild(Torso, "Neck")
  252. local Humanoid = waitForChild(Figure, "Humanoid")
  253. local pose = "Standing"
  254.  
  255. local currentAnim = ""
  256. local currentAnimTrack = nil
  257. local currentAnimKeyframeHandler = nil
  258. local oldAnimTrack = nil
  259. local animTable = {}
  260. local animNames = {
  261. idle = {
  262. { id = "http://www.roblox.com/asset/?id=125750544", weight = 9 },
  263. { id = "http://www.roblox.com/asset/?id=125750618", weight = 1 }
  264. },
  265. walk = {
  266. { id = "http://www.roblox.com/asset/?id=125749145", weight = 10 }
  267. },
  268. run = {
  269. { id = "run.xml", weight = 10 }
  270. },
  271. jump = {
  272. { id = "http://www.roblox.com/asset/?id=125750702", weight = 10 }
  273. },
  274. fall = {
  275. { id = "http://www.roblox.com/asset/?id=125750759", weight = 10 }
  276. },
  277. climb = {
  278. { id = "http://www.roblox.com/asset/?id=125750800", weight = 10 }
  279. },
  280. toolnone = {
  281. { id = "http://www.roblox.com/asset/?id=125750867", weight = 10 }
  282. },
  283. toolslash = {
  284. { id = "http://www.roblox.com/asset/?id=129967390", weight = 10 }
  285. -- { id = "slash.xml", weight = 10 }
  286. },
  287. toollunge = {
  288. { id = "http://www.roblox.com/asset/?id=129967478", weight = 10 }
  289. },
  290. wave = {
  291. { id = "http://www.roblox.com/asset/?id=128777973", weight = 10 }
  292. },
  293. point = {
  294. { id = "http://www.roblox.com/asset/?id=128853357", weight = 10 }
  295. },
  296. dance = {
  297. { id = "http://www.roblox.com/asset/?id=130018893", weight = 10 },
  298. { id = "http://www.roblox.com/asset/?id=132546839", weight = 10 },
  299. { id = "http://www.roblox.com/asset/?id=132546884", weight = 10 }
  300. },
  301. laugh = {
  302. { id = "http://www.roblox.com/asset/?id=129423131", weight = 10 }
  303. },
  304. cheer = {
  305. { id = "http://www.roblox.com/asset/?id=129423030", weight = 10 }
  306. },
  307. }
  308.  
  309. -- Existance in this list signifies that it is an emote, the value indicates If it is a looping emote
  310. local emoteNames = { wave = false, point = false, dance = true, laugh = false, cheer = false}
  311.  
  312. math.randomseed(tick())
  313.  
  314. -- Setup animation objects
  315. for name, fileList in pairs(animNames) do
  316. animTable[name] = {}
  317. animTable[name].count = 0
  318. animTable[name].totalWeight = 0
  319.  
  320. -- check for config values
  321. local config = script:FindFirstChild(name)
  322. if (config ~= nil) then
  323. -- print("Loading anims " .. name)
  324. local idx = 1
  325. for _, childPart in pairs(config:GetChildren()) do
  326. animTable[name][idx] = {}
  327. animTable[name][idx].anim = childPart
  328. local weightObject = childPart:FindFirstChild("Weight")
  329. if (weightObject == nil) then
  330. animTable[name][idx].weight = 1
  331. else
  332. animTable[name][idx].weight = weightObject.Value
  333. end
  334. animTable[name].count = animTable[name].count + 1
  335. animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight
  336. -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")")
  337. idx = idx + 1
  338. end
  339. end
  340.  
  341. -- fallback to defaults
  342. if (animTable[name].count <= 0) then
  343. for idx, anim in pairs(fileList) do
  344. animTable[name][idx] = {}
  345. animTable[name][idx].anim = Instance.new("Animation")
  346. animTable[name][idx].anim.Name = name
  347. animTable[name][idx].anim.AnimationId = anim.id
  348. animTable[name][idx].weight = anim.weight
  349. animTable[name].count = animTable[name].count + 1
  350. animTable[name].totalWeight = animTable[name].totalWeight + anim.weight
  351. -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")")
  352. end
  353. end
  354. end
  355.  
  356. -- ANIMATION
  357.  
  358. -- declarations
  359. local toolAnim = "None"
  360. local toolAnimTime = 0
  361.  
  362. local jumpAnimTime = 0
  363. local jumpAnimDuration = 0.175
  364.  
  365. local toolTransitionTime = 0.1
  366. local fallTransitionTime = 0.2
  367. local jumpMaxLimbVelocity = 0.75
  368.  
  369. -- functions
  370.  
  371. function stopAllAnimations()
  372. local oldAnim = currentAnim
  373.  
  374. -- return to idle If finishing an emote
  375. if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then
  376. oldAnim = "idle"
  377. end
  378.  
  379. currentAnim = ""
  380. if (currentAnimKeyframeHandler ~= nil) then
  381. currentAnimKeyframeHandler:disconnect()
  382. end
  383.  
  384. if (oldAnimTrack ~= nil) then
  385. oldAnimTrack:Stop()
  386. oldAnimTrack:Destroy()
  387. oldAnimTrack = nil
  388. end
  389. if (currentAnimTrack ~= nil) then
  390. currentAnimTrack:Stop()
  391. currentAnimTrack:Destroy()
  392. currentAnimTrack = nil
  393. end
  394. return oldAnim
  395. end
  396.  
  397. function keyFrameReachedFunc(frameName)
  398. if (frameName == "End") then
  399. -- print("Keyframe : ".. frameName)
  400. local repeatAnim = stopAllAnimations()
  401. playAnimation(repeatAnim, 0.0, Humanoid)
  402. end
  403. end
  404.  
  405. -- Preload animations
  406. function playAnimation(animName, transitionTime, humanoid)
  407. if (animName ~= currentAnim) then
  408.  
  409. if (oldAnimTrack ~= nil) then
  410. oldAnimTrack:Stop()
  411. oldAnimTrack:Destroy()
  412. end
  413.  
  414. local roll = math.random(1, animTable[animName].totalWeight)
  415. local origRoll = roll
  416. local idx = 1
  417. while (roll > animTable[animName][idx].weight) do
  418. roll = roll - animTable[animName][idx].weight
  419. idx = idx + 1
  420. end
  421. -- print(animName .. " " .. idx .. " [" .. origRoll .. "]")
  422. local anim = animTable[animName][idx].anim
  423.  
  424. -- load it to the humanoid; get AnimationTrack
  425. oldAnimTrack = currentAnimTrack
  426. currentAnimTrack = humanoid:LoadAnimation(anim)
  427.  
  428. -- play the animation
  429. currentAnimTrack:Play(transitionTime)
  430. currentAnim = animName
  431.  
  432. -- set up keyframe name triggers
  433. if (currentAnimKeyframeHandler ~= nil) then
  434. currentAnimKeyframeHandler:disconnect()
  435. end
  436. currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc)
  437. end
  438. end
  439.  
  440. -------------------------------------------------------------------------------------------
  441. -------------------------------------------------------------------------------------------
  442.  
  443. local toolAnimName = ""
  444. local toolOldAnimTrack = nil
  445. local toolAnimTrack = nil
  446. local currentToolAnimKeyframeHandler = nil
  447.  
  448. function toolKeyFrameReachedFunc(frameName)
  449. if (frameName == "End") then
  450. -- print("Keyframe : ".. frameName)
  451. local repeatAnim = stopToolAnimations()
  452. playToolAnimation(repeatAnim, 0.0, Humanoid)
  453. end
  454. end
  455.  
  456.  
  457. function playToolAnimation(animName, transitionTime, humanoid)
  458. if (animName ~= toolAnimName) then
  459.  
  460. if (toolAnimTrack ~= nil) then
  461. toolAnimTrack:Stop()
  462. toolAnimTrack:Destroy()
  463. transitionTime = 0
  464. end
  465.  
  466. local roll = math.random(1, animTable[animName].totalWeight)
  467. local origRoll = roll
  468. local idx = 1
  469. while (roll > animTable[animName][idx].weight) do
  470. roll = roll - animTable[animName][idx].weight
  471. idx = idx + 1
  472. end
  473. -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
  474. local anim = animTable[animName][idx].anim
  475.  
  476. -- load it to the humanoid; get AnimationTrack
  477. toolOldAnimTrack = toolAnimTrack
  478. toolAnimTrack = humanoid:LoadAnimation(anim)
  479.  
  480. -- play the animation
  481. toolAnimTrack:Play(transitionTime)
  482. toolAnimName = animName
  483.  
  484. currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
  485. end
  486. end
  487.  
  488. function stopToolAnimations()
  489. local oldAnim = toolAnimName
  490.  
  491. if (currentToolAnimKeyframeHandler ~= nil) then
  492. currentToolAnimKeyframeHandler:disconnect()
  493. end
  494.  
  495. toolAnimName = ""
  496. if (toolAnimTrack ~= nil) then
  497. toolAnimTrack:Stop()
  498. toolAnimTrack:Destroy()
  499. toolAnimTrack = nil
  500. end
  501.  
  502.  
  503. return oldAnim
  504. end
  505.  
  506. -------------------------------------------------------------------------------------------
  507. -------------------------------------------------------------------------------------------
  508.  
  509.  
  510. function onRunning(speed)
  511. if speed>0 then
  512. playAnimation("walk", 0.1, Humanoid)
  513. pose = "Running"
  514. else
  515. playAnimation("idle", 0.1, Humanoid)
  516. pose = "Standing"
  517. end
  518. end
  519.  
  520. function onDied()
  521. pose = "Dead"
  522. end
  523.  
  524. function onJumping()
  525. playAnimation("jump", 0.1, Humanoid)
  526. jumpAnimTime = jumpAnimDuration
  527. pose = "Jumping"
  528. end
  529.  
  530. function onClimbing()
  531. playAnimation("climb", 0.1, Humanoid)
  532. pose = "Climbing"
  533. end
  534.  
  535. function onGettingUp()
  536. pose = "GettingUp"
  537. end
  538.  
  539. function onFreeFall()
  540. if (jumpAnimTime <= 0) then
  541. playAnimation("fall", fallTransitionTime, Humanoid)
  542. end
  543. pose = "FreeFall"
  544. end
  545.  
  546. function onFallingDown()
  547. pose = "FallingDown"
  548. end
  549.  
  550. function onSeated()
  551. pose = "Seated"
  552. end
  553.  
  554. function onPlatformStanding()
  555. pose = "PlatformStanding"
  556. end
  557.  
  558. function onSwimming(speed)
  559. if speed>0 then
  560. pose = "Running"
  561. else
  562. pose = "Standing"
  563. end
  564. end
  565.  
  566. function getTool()
  567. for _, kid in ipairs(Figure:GetChildren()) do
  568. if kid.className == "Tool" then return kid end
  569. end
  570. return nil
  571. end
  572.  
  573. function getToolAnim(tool)
  574. for _, c in ipairs(tool:GetChildren()) do
  575. if c.Name == "toolanim" and c.className == "StringValue" then
  576. return c
  577. end
  578. end
  579. return nil
  580. end
  581.  
  582. function animateTool()
  583.  
  584. if (toolAnim == "None") then
  585. playToolAnimation("toolnone", toolTransitionTime, Humanoid)
  586. return
  587. end
  588.  
  589. if (toolAnim == "Slash") then
  590. playToolAnimation("toolslash", 0, Humanoid)
  591. return
  592. end
  593.  
  594. if (toolAnim == "Lunge") then
  595. playToolAnimation("toollunge", 0, Humanoid)
  596. return
  597. end
  598. end
  599.  
  600. function moveSit()
  601. RightHip:SetDesiredAngle(3.14 /2)
  602. LeftHip:SetDesiredAngle(-3.14 /2)
  603. end
  604.  
  605. local lastTick = 0
  606.  
  607. function move(time)
  608. local amplitude = 1
  609. local frequency = 1
  610. local deltaTime = time - lastTick
  611. lastTick = time
  612.  
  613. local climbFudge = 0
  614. local setAngles = false
  615.  
  616. if (jumpAnimTime > 0) then
  617. jumpAnimTime = jumpAnimTime - deltaTime
  618. end
  619.  
  620. if (pose == "FreeFall" and jumpAnimTime <= 0) then
  621. playAnimation("fall", fallTransitionTime, Humanoid)
  622. elseif (pose == "Seated") then
  623. stopAllAnimations()
  624. moveSit()
  625. return
  626. elseif (pose == "Running") then
  627. playAnimation("walk", 0.1, Humanoid)
  628. elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then
  629. -- print("Wha " .. pose)
  630. amplitude = 0.1
  631. frequency = 1
  632. setAngles = true
  633. end
  634.  
  635. if (setAngles) then
  636. desiredAngle = amplitude * math.sin(time * frequency)
  637.  
  638. RightHip:SetDesiredAngle(-desiredAngle)
  639. LeftHip:SetDesiredAngle(-desiredAngle)
  640. end
  641.  
  642. -- Tool Animation handling
  643. local tool = getTool()
  644. if tool then
  645.  
  646. animStringValueObject = getToolAnim(tool)
  647.  
  648. if animStringValueObject then
  649. toolAnim = animStringValueObject.Value
  650. -- message recieved, delete StringValue
  651. animStringValueObject.Parent = nil
  652. toolAnimTime = time + .3
  653. end
  654.  
  655. if time > toolAnimTime then
  656. toolAnimTime = 0
  657. toolAnim = "None"
  658. end
  659.  
  660. animateTool()
  661. else
  662. stopToolAnimations()
  663. toolAnim = "None"
  664. toolAnimTime = 0
  665. end
  666. end
  667.  
  668. -- connect events
  669. Humanoid.Died:connect(onDied)
  670. Humanoid.Running:connect(onRunning)
  671. Humanoid.Jumping:connect(onJumping)
  672. Humanoid.Climbing:connect(onClimbing)
  673. Humanoid.GettingUp:connect(onGettingUp)
  674. Humanoid.FreeFalling:connect(onFreeFall)
  675. Humanoid.FallingDown:connect(onFallingDown)
  676. Humanoid.Seated:connect(onSeated)
  677. Humanoid.PlatformStanding:connect(onPlatformStanding)
  678. Humanoid.Swimming:connect(onSwimming)
  679. -- main program
  680.  
  681. local runService = game:service("RunService");
  682.  
  683. -- initialize to idle
  684. playAnimation("idle", 0.1, Humanoid)
  685. pose = "Standing"
  686.  
  687. while Figure.Parent~=nil do
  688. local _, time = wait(0.1)
  689. move(time)
  690. end
  691.  
  692. end))
  693. StringValue22.Name = "climb"
  694. StringValue22.Parent = Script21
  695. Animation23.Name = "ClimbAnim"
  696. Animation23.Parent = StringValue22
  697. Animation23.AnimationId = "http://www.roblox.com/asset/?id=125750800"
  698. StringValue24.Name = "fall"
  699. StringValue24.Parent = Script21
  700. Animation25.Name = "FallAnim"
  701. Animation25.Parent = StringValue24
  702. Animation25.AnimationId = "http://www.roblox.com/asset/?id=125750759"
  703. StringValue26.Name = "idle"
  704. StringValue26.Parent = Script21
  705. Animation27.Name = "Animation1"
  706. Animation27.Parent = StringValue26
  707. Animation27.AnimationId = "http://www.roblox.com/asset/?id=125750544"
  708. NumberValue28.Name = "Weight"
  709. NumberValue28.Parent = Animation27
  710. NumberValue28.Value = 9
  711. Animation29.Name = "Animation2"
  712. Animation29.Parent = StringValue26
  713. Animation29.AnimationId = "http://www.roblox.com/asset/?id=125750618"
  714. NumberValue30.Name = "Weight"
  715. NumberValue30.Parent = Animation29
  716. NumberValue30.Value = 1
  717. StringValue31.Name = "jump"
  718. StringValue31.Parent = Script21
  719. Animation32.Name = "JumpAnim"
  720. Animation32.Parent = StringValue31
  721. Animation32.AnimationId = "http://www.roblox.com/asset/?id=125750702"
  722. StringValue33.Name = "run"
  723. StringValue33.Parent = Script21
  724. Animation34.Name = "RunAnim"
  725. Animation34.Parent = StringValue33
  726. Animation34.AnimationId = "http://www.roblox.com/asset/?id=125749145"
  727. StringValue35.Name = "toolnone"
  728. StringValue35.Parent = Script21
  729. Animation36.Name = "ToolNoneAnim"
  730. Animation36.Parent = StringValue35
  731. Animation36.AnimationId = "http://www.roblox.com/asset/?id=125750867"
  732. StringValue37.Name = "walk"
  733. StringValue37.Parent = Script21
  734. Animation38.Name = "WalkAnim"
  735. Animation38.Parent = StringValue37
  736. Animation38.AnimationId = "http://www.roblox.com/asset/?id=125749145"
  737. Script39.Name = "Control"
  738. Script39.Parent = Model0
  739. table.insert(cors,sandbox(Script39,function()
  740. wait(.1)
  741. local ammo=29
  742. local w=.14
  743. local r=false
  744. local t=script.Parent
  745. Spawn(function()
  746. local c=t:Clone()
  747. t.Humanoid.Died:wait()
  748. t.Handle:Destroy()
  749. script.Parent.Head.Die:Play()
  750.  
  751. wait(3)
  752. c.Parent=workspace
  753. c:MakeJoints()
  754. t:Destroy()
  755.  
  756. end)
  757. local cf={CFrame.new(.8,.5,.4)*CFrame.Angles(math.rad(270),math.rad(40),0),CFrame.new(-1.2,0.5,0.4)*CFrame.Angles(math.rad(270),math.rad(-5),0)}
  758. local c=LoadLibrary'RbxUtility'.Create
  759. local b1=c'Part'{TopSurface=0;BottomSurface=0;Anchored=true;CanCollide=false;Material="Neon";Transparency=0.3;BrickColor=BrickColor.Yellow();Size=Vector3.new(.2,.2,1);c'BlockMesh'{Scale=Vector3.new(.2,.2,1)}}
  760. local b2=b1:Clone()
  761. b1.Name,b2.Name='1','2'
  762. local mov=c'Part'{Transparency=1;CanCollide=false;Parent=t;Anchored=true}
  763. local h=t:WaitForChild'Handle'
  764. local function reload(boo)
  765. if(boo and ammo~=30)or ammo==0 then
  766. r=true
  767. if w then
  768. w=.03
  769. end
  770. h.Reload:Play()
  771. wait(3)
  772. ammo=30
  773. if w then
  774. w=.14
  775. end
  776. r=false
  777. elseif boo then
  778. wait(.1)
  779. end
  780. end
  781. local function near()
  782. local dis,pl=200,nil
  783.  
  784. for _,v in ipairs(game.Players:GetPlayers())do
  785. if v.Character and v.Character:FindFirstChild'Humanoid'and v:DistanceFromCharacter(h.Position)<dis then
  786. dis,pl=v:DistanceFromCharacter(h.Position),v
  787.  
  788. end
  789. end
  790.  
  791.  
  792.  
  793.  
  794. if pl then
  795. return pl.Character:GetModelCFrame(),dis,CFrame.new(pl.Character.Humanoid.WalkToPoint).lookVector
  796.  
  797. else
  798. return nil
  799. end
  800. end
  801.  
  802.  
  803. Spawn(function()
  804. while true do
  805. t.Humanoid.Jump=true
  806. while not w do wait(4)end
  807. for i=1,math.random(150,160)do
  808. wait(w)
  809. end
  810. end
  811. end)
  812. Spawn(function()
  813. while wait(math.random(2,7)/10)do
  814. local n=near()
  815. if n and math.random(1,7)==2 or not n then
  816. mov.CFrame=t.Torso.CFrame+t.Torso.CFrame.lookVector*Vector3.new(math.random(-50,50),0,math.random(-35,50))
  817. else
  818. mov.CFrame=n+Vector3.new((math.random(1,2)==1 and 1 or -1)*math.random(25,50),0,(math.random(1,2)==1 and 1 or -1)*math.random(25,50))
  819. end
  820. wait(0.4)
  821. t.Humanoid:MoveTo(mov.Position,mov)
  822.  
  823. end
  824. end)
  825. while true do
  826. local n,mag,hum=near()
  827. if n then
  828. n=n.p
  829. if not r then
  830. w=.0001
  831. local dir=h.Position-n
  832. local tst,_=workspace:FindPartOnRay(Ray.new(t.Torso.Position,(n-t.Torso.Position).Unit*99999),t)
  833. local aim=n+Vector3.new(math.random(-mag*.008,mag*.008),math.random(-mag*.009,mag*.009),math.random(-mag*.1,mag*.1))*(2+math.random())+hum
  834. if tst and tst.Parent and game.Players:GetPlayerFromCharacter(tst.Parent)then
  835.  
  836. wait(0.04)
  837. h.Fire:Play()
  838. local par,pos=workspace:FindPartOnRay(Ray.new(h.Position,(aim-h.Position).Unit*99999),t)
  839. if par then
  840. local h=par.Parent:FindFirstChild'Humanoid'or par.Parent.Parent:FindFirstChild'Humanoid'
  841. if h and h.Health-10>0 then
  842. h.Health=h.Health-10
  843. elseif h then
  844. h.Health=0
  845. h.Parent:BreakJoints()
  846.  
  847. end
  848. end
  849. ammo=ammo-1
  850. mag=(h.Position-pos).magnitude
  851. b1.Parent,b2.Parent=t,t
  852. b1.CFrame,b2.CFrame=CFrame.new(h.Position:Lerp(pos,.375),pos),CFrame.new(pos:Lerp(h.Position,.125),h.Position)
  853. b1.Mesh.Scale,b2.Mesh.Scale=Vector3.new(.2,.2,mag*.75),Vector3.new(.2,.2,mag/4)
  854. Delay(.03,function()b1.Parent=nil wait(.03)b2.Parent=nil end)
  855. end
  856. wait(.05)
  857. if ammo==0 then
  858. reload()
  859. end
  860. end
  861. else
  862. reload(true)
  863. w=false
  864. end
  865. end
  866.  
  867. end))
  868. Shirt40.Name = "Shirt"
  869. Shirt40.Parent = Model0
  870. Shirt40.ShirtTemplate = "http://www.roblox.com/asset/?id=26349286"
  871. Pants41.Name = "Pants"
  872. Pants41.Parent = Model0
  873. Pants41.PantsTemplate = "http://www.roblox.com/asset/?id=26349271"
  874. Hat42.Name = "Helm"
  875. Hat42.Parent = Model0
  876. Hat42.AttachmentForward = Vector3.new(0, -0.196116135, -0.980580688)
  877. Hat42.AttachmentPos = Vector3.new(0, -0.100000001, -0.0700000003)
  878. Hat42.AttachmentUp = Vector3.new(0, 0.980580688, -0.196116135)
  879. Part43.Name = "Handle"
  880. Part43.Parent = Hat42
  881. Part43.Material = Enum.Material.CorrodedMetal
  882. Part43.BrickColor = BrickColor.new("Black")
  883. Part43.Rotation = Vector3.new(90, -78.6899948, 90)
  884. Part43.CanCollide = false
  885. Part43.FormFactor = Enum.FormFactor.Symmetric
  886. Part43.Size = Vector3.new(1, 1, 1)
  887. Part43.CFrame = CFrame.new(12.3637447, 5.08433008, 63.8128319, -5.73683906e-07, -0.196116149, -0.980580688, 7.667877e-09, 0.980580688, -0.196116149, 1, -1.2002765e-07, -5.61039542e-07)
  888. Part43.BottomSurface = Enum.SurfaceType.Smooth
  889. Part43.TopSurface = Enum.SurfaceType.Smooth
  890. Part43.Color = Color3.new(0.164706, 0.176471, 0.0823529)
  891. Part43.Position = Vector3.new(12.3637447, 5.08433008, 63.8128319)
  892. Part43.Orientation = Vector3.new(11.3099995, -90, 0)
  893. Part43.Color = Color3.new(0.164706, 0.176471, 0.0823529)
  894. SpecialMesh44.Parent = Part43
  895. SpecialMesh44.MeshId = "http://www.roblox.com/asset/?id=45609892"
  896. SpecialMesh44.Offset = Vector3.new(0, 0.0500000007, -0.150000006)
  897. SpecialMesh44.Scale = Vector3.new(1.5, 1.5, 1.5)
  898. SpecialMesh44.MeshType = Enum.MeshType.FileMesh
  899. SpecialMesh44.Scale = Vector3.new(1.5, 1.5, 1.5)
  900. Part45.Name = "Handle"
  901. Part45.Parent = Model0
  902. Part45.BrickColor = BrickColor.new("Dark stone grey")
  903. Part45.Transparency = 1
  904. Part45.Rotation = Vector3.new(0, 5, 0)
  905. Part45.CanCollide = false
  906. Part45.FormFactor = Enum.FormFactor.Symmetric
  907. Part45.Size = Vector3.new(2, 1, 1)
  908. Part45.CFrame = CFrame.new(14.0334444, 3.5999999, 64.678299, 0.99619478, 2.74879053e-09, 0.0871551633, -3.49720697e-09, 1, 8.4344931e-09, -0.0871551633, -8.70719674e-09, 0.99619478)
  909. Part45.RightSurface = Enum.SurfaceType.Hinge
  910. Part45.Color = Color3.new(0.388235, 0.372549, 0.384314)
  911. Part45.Position = Vector3.new(14.0334444, 3.5999999, 64.678299)
  912. Part45.Orientation = Vector3.new(0, 5, 0)
  913. Part45.Color = Color3.new(0.388235, 0.372549, 0.384314)
  914. Sound46.Name = "Reload"
  915. Sound46.Parent = Part45
  916. Sound46.Pitch = 0.80000001192093
  917. Sound46.SoundId = "rbxassetid://657701831"
  918. Sound46.Volume = 1
  919. Sound47.Name = "Fire"
  920. Sound47.Parent = Part45
  921. Sound47.SoundId = "rbxassetid://541454470"
  922. Sound47.Volume = 1
  923. Part48.Parent = Part45
  924. Part48.Rotation = Vector3.new(-5, -90, 0)
  925. Part48.Size = Vector3.new(0.299999595, 1, 2)
  926. Part48.CFrame = CFrame.new(14.380682, 3.71998262, 64.4170761, -9.3130501e-07, 7.96250106e-08, -1, 0.087155737, 0.99619478, -1.84656812e-09, 0.99619472, -0.0871557444, -9.34700893e-07)
  927. Part48.Position = Vector3.new(14.380682, 3.71998262, 64.4170761)
  928. Part48.Orientation = Vector3.new(0, -90, 5)
  929. SpecialMesh49.Parent = Part48
  930. SpecialMesh49.MeshId = "rbxassetid://477918514"
  931. SpecialMesh49.Scale = Vector3.new(0.0299999993, 0.0299999993, 0.0299999993)
  932. SpecialMesh49.TextureId = "rbxassetid://477918517"
  933. SpecialMesh49.MeshType = Enum.MeshType.FileMesh
  934. SpecialMesh49.Scale = Vector3.new(0.0299999993, 0.0299999993, 0.0299999993)
  935. Script50.Name = "qPerfectionWeld"
  936. Script50.Parent = Part45
  937. table.insert(cors,sandbox(Script50,function()
  938. -- Created by Quenty (@Quenty, follow me on twitter).
  939. -- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
  940. -- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
  941.  
  942. --[[ INSTRUCTIONS
  943. - Place in the model
  944. - Make sure model is anchored
  945. - That's it. It will weld the model and all children.
  946.  
  947. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  948. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  949. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  950. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  951. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  952. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  953. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  954. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  955.  
  956. This script is designed to be used is a regular script. In a local script it will weld, but it will not attempt to handle ancestory changes.
  957. ]]
  958.  
  959. --[[ DOCUMENTATION
  960. - Will work in tools. If ran more than once it will not create more than one weld. This is especially useful for tools that are dropped and then picked up again.
  961. - Will work in PBS servers
  962. - Will work as long as it starts out with the part anchored
  963. - Stores the relative CFrame as a CFrame value
  964. - Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
  965. - Utilizes a recursive algorith to find all parts in the model
  966. - Will reweld on script reparent if the script is initially parented to a tool.
  967. - Welds as fast as possible
  968. ]]
  969.  
  970. -- qPerfectionWeld.lua
  971. -- Created 10/6/2014
  972. -- Author: Quenty
  973. -- Version 1.0.3
  974.  
  975. -- Updated 10/14/2014 - Updated to 1.0.1
  976. --- Bug fix with existing ROBLOX welds ? Repro by asimo3089
  977.  
  978. -- Updated 10/14/2014 - Updated to 1.0.2
  979. --- Fixed bug fix.
  980.  
  981. -- Updated 10/14/2014 - Updated to 1.0.3
  982. --- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
  983.  
  984. local NEVER_BREAK_JOINTS = false -- If you set this to true it will never break joints (this can create some welding issues, but can save stuff like hinges).
  985.  
  986.  
  987. local function CallOnChildren(Instance, FunctionToCall)
  988. -- Calls a function on each of the children of a certain object, using recursion.
  989.  
  990. FunctionToCall(Instance)
  991.  
  992. for _, Child in next, Instance:GetChildren() do
  993. CallOnChildren(Child, FunctionToCall)
  994. end
  995. end
  996.  
  997. local function GetNearestParent(Instance, ClassName)
  998. -- Returns the nearest parent of a certain class, or returns nil
  999.  
  1000. local Ancestor = Instance
  1001. repeat
  1002. Ancestor = Ancestor.Parent
  1003. if Ancestor == nil then
  1004. return nil
  1005. end
  1006. until Ancestor:IsA(ClassName)
  1007.  
  1008. return Ancestor
  1009. end
  1010.  
  1011. local function GetBricks(StartInstance)
  1012. local List = {}
  1013.  
  1014. -- if StartInstance:IsA("BasePart") then
  1015. -- List[#List+1] = StartInstance
  1016. -- end
  1017.  
  1018. CallOnChildren(StartInstance, function(Item)
  1019. if Item:IsA("BasePart") then
  1020. List[#List+1] = Item;
  1021. end
  1022. end)
  1023.  
  1024. return List
  1025. end
  1026.  
  1027. local function Modify(Instance, Values)
  1028. -- Modifies an Instance by using a table.
  1029.  
  1030. assert(type(Values) == "table", "Values is not a table");
  1031.  
  1032. for Index, Value in next, Values do
  1033. if type(Index) == "number" then
  1034. Value.Parent = Instance
  1035. else
  1036. Instance[Index] = Value
  1037. end
  1038. end
  1039. return Instance
  1040. end
  1041.  
  1042. local function Make(ClassType, Properties)
  1043. -- Using a syntax hack to create a nice way to Make new items.
  1044.  
  1045. return Modify(Instance.new(ClassType), Properties)
  1046. end
  1047.  
  1048. local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
  1049. local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
  1050.  
  1051. local function HasWheelJoint(Part)
  1052. for _, SurfaceName in pairs(Surfaces) do
  1053. for _, HingSurfaceName in pairs(HingSurfaces) do
  1054. if Part[SurfaceName].Name == HingSurfaceName then
  1055. return true
  1056. end
  1057. end
  1058. end
  1059.  
  1060. return false
  1061. end
  1062.  
  1063. local function ShouldBreakJoints(Part)
  1064. --- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
  1065. -- definitely some edge cases.
  1066.  
  1067. if NEVER_BREAK_JOINTS then
  1068. return false
  1069. end
  1070.  
  1071. if HasWheelJoint(Part) then
  1072. return false
  1073. end
  1074.  
  1075. local Connected = Part:GetConnectedParts()
  1076.  
  1077. if #Connected == 1 then
  1078. return false
  1079. end
  1080.  
  1081. for _, Item in pairs(Connected) do
  1082. if HasWheelJoint(Item) then
  1083. return false
  1084. elseif not Item:IsDescendantOf(script.Parent) then
  1085. return false
  1086. end
  1087. end
  1088.  
  1089. return true
  1090. end
  1091.  
  1092. local function WeldTogether(Part0, Part1, JointType, WeldParent)
  1093. --- Weld's 2 parts together
  1094. -- @param Part0 The first part
  1095. -- @param Part1 The second part (Dependent part most of the time).
  1096. -- @param [JointType] The type of joint. Defaults to weld.
  1097. -- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
  1098. -- @return The weld created.
  1099.  
  1100. JointType = JointType or "Weld"
  1101. local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
  1102.  
  1103. local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
  1104. Modify(NewWeld, {
  1105. Name = "qCFrameWeldThingy";
  1106. Part0 = Part0;
  1107. Part1 = Part1;
  1108. C0 = CFrame.new();--Part0.CFrame:inverse();
  1109. C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
  1110. Parent = Part1;
  1111. })
  1112.  
  1113. if not RelativeValue then
  1114. RelativeValue = Make("CFrameValue", {
  1115. Parent = Part1;
  1116. Name = "qRelativeCFrameWeldValue";
  1117. Archivable = true;
  1118. Value = NewWeld.C1;
  1119. })
  1120. end
  1121.  
  1122. return NewWeld
  1123. end
  1124.  
  1125. local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
  1126. -- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
  1127. -- @param MainPart The part to weld the model to (can be in the model).
  1128. -- @param [JointType] The type of joint. Defaults to weld.
  1129. -- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
  1130.  
  1131. for _, Part in pairs(Parts) do
  1132. if ShouldBreakJoints(Part) then
  1133. Part:BreakJoints()
  1134. end
  1135. end
  1136.  
  1137. for _, Part in pairs(Parts) do
  1138. if Part ~= MainPart then
  1139. WeldTogether(MainPart, Part, JointType, MainPart)
  1140. end
  1141. end
  1142.  
  1143. if not DoNotUnanchor then
  1144. for _, Part in pairs(Parts) do
  1145. Part.Anchored = false
  1146. end
  1147. MainPart.Anchored = false
  1148. end
  1149. end
  1150.  
  1151. local function PerfectionWeld()
  1152. local Tool = GetNearestParent(script, "Tool")
  1153.  
  1154. local Parts = GetBricks(script.Parent)
  1155. local PrimaryPart = Tool and Tool:FindFirstChild("Handle") and Tool.Handle:IsA("BasePart") and Tool.Handle or script.Parent:IsA("Model") and script.Parent.PrimaryPart or Parts[1]
  1156.  
  1157. if PrimaryPart then
  1158. WeldParts(Parts, PrimaryPart, "Weld", false)
  1159. else
  1160. warn("qWeld - Unable to weld part")
  1161. end
  1162.  
  1163. return Tool
  1164. end
  1165.  
  1166. local Tool = PerfectionWeld()
  1167.  
  1168.  
  1169. if Tool and script.ClassName == "Script" then
  1170. --- Don't bother with local scripts
  1171.  
  1172. script.Parent.AncestryChanged:connect(function()
  1173. PerfectionWeld()
  1174. end)
  1175. end
  1176.  
  1177. -- Created by Quenty (@Quenty, follow me on twitter).
  1178.  
  1179. end))
  1180. Humanoid51.Parent = Model0
  1181. Humanoid51.NameOcclusion = Enum.NameOcclusion.NoOcclusion
  1182. Humanoid51.RightLeg = Part18
  1183. Humanoid51.LeftLeg = Part17
  1184. Humanoid51.Torso = Part19
  1185. Hat52.Name = "Millitary Beanie"
  1186. Hat52.Parent = Model0
  1187. Hat52.AttachmentPos = Vector3.new(0, -0.100000001, -0.0700000003)
  1188. Part53.Name = "Handle"
  1189. Part53.Parent = Hat52
  1190. Part53.BrickColor = BrickColor.new("Pastel brown")
  1191. Part53.Rotation = Vector3.new(0, -90, 0)
  1192. Part53.CanCollide = false
  1193. Part53.FormFactor = Enum.FormFactor.Symmetric
  1194. Part53.Size = Vector3.new(1, 1, 1)
  1195. Part53.CFrame = CFrame.new(12.3819971, 5.0999999, 63.8128319, -5.73683906e-07, -9.13071307e-09, -1, 7.667877e-09, 1, -9.13071752e-09, 1, -7.66788233e-09, -5.73683906e-07)
  1196. Part53.BottomSurface = Enum.SurfaceType.Smooth
  1197. Part53.TopSurface = Enum.SurfaceType.Smooth
  1198. Part53.Color = Color3.new(1, 0.8, 0.6)
  1199. Part53.Position = Vector3.new(12.3819971, 5.0999999, 63.8128319)
  1200. Part53.Orientation = Vector3.new(0, -90, 0)
  1201. Part53.Color = Color3.new(1, 0.8, 0.6)
  1202. SpecialMesh54.Parent = Part53
  1203. SpecialMesh54.MeshId = "rbxassetid://11349749"
  1204. SpecialMesh54.Offset = Vector3.new(0, -0.400000006, -0.300000012)
  1205. SpecialMesh54.TextureId = "rbxassetid://29875340"
  1206. SpecialMesh54.MeshType = Enum.MeshType.FileMesh
  1207. for i,v in pairs(mas:GetChildren()) do
  1208. v.Parent = workspace
  1209. pcall(function() v:MakeJoints() end)
  1210. end
  1211. mas:Destroy()
  1212. for i,v in pairs(cors) do
  1213. spawn(function()
  1214. pcall(v)
  1215. end)
  1216. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement