Advertisement
okban

test

Feb 21st, 2018
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.51 KB | None | 0 0
  1. function sandbox(var,func)
  2. local env = getfenv(func)
  3. local newenv = setmetatable({},{
  4. __index = function(self,k)
  5. if k=="script" then
  6. return var
  7. else
  8. return env[k]
  9. end
  10. end,
  11. })
  12. setfenv(func,newenv)
  13. return func
  14. end
  15. cors = {}
  16. mas = Instance.new("Model",game:GetService("Lighting"))
  17. Tool0 = Instance.new("Tool")
  18. Script1 = Instance.new("Script")
  19. Folder2 = Instance.new("Folder")
  20. Folder3 = Instance.new("Folder")
  21. Animation4 = Instance.new("Animation")
  22. Animation5 = Instance.new("Animation")
  23. Animation6 = Instance.new("Animation")
  24. Folder7 = Instance.new("Folder")
  25. Animation8 = Instance.new("Animation")
  26. Animation9 = Instance.new("Animation")
  27. Animation10 = Instance.new("Animation")
  28. Part11 = Instance.new("Part")
  29. CylinderMesh12 = Instance.new("CylinderMesh")
  30. SurfaceLight13 = Instance.new("SurfaceLight")
  31. SurfaceLight14 = Instance.new("SurfaceLight")
  32. SurfaceLight15 = Instance.new("SurfaceLight")
  33. SurfaceLight16 = Instance.new("SurfaceLight")
  34. SurfaceLight17 = Instance.new("SurfaceLight")
  35. SurfaceLight18 = Instance.new("SurfaceLight")
  36. Attachment19 = Instance.new("Attachment")
  37. Attachment20 = Instance.new("Attachment")
  38. Script21 = Instance.new("Script")
  39. Part22 = Instance.new("Part")
  40. CylinderMesh23 = Instance.new("CylinderMesh")
  41. Part24 = Instance.new("Part")
  42. CylinderMesh25 = Instance.new("CylinderMesh")
  43. Script26 = Instance.new("Script")
  44. Part27 = Instance.new("Part")
  45. SpecialMesh28 = Instance.new("SpecialMesh")
  46. Attachment29 = Instance.new("Attachment")
  47. Motor6D30 = Instance.new("Motor6D")
  48. Sound31 = Instance.new("Sound")
  49. Sound32 = Instance.new("Sound")
  50. Sound33 = Instance.new("Sound")
  51. Sound34 = Instance.new("Sound")
  52. Sound35 = Instance.new("Sound")
  53. Sound36 = Instance.new("Sound")
  54. Tool0.Name = "KyloLightsaber"
  55. Tool0.Parent = mas
  56. Tool0.TextureId = "rbxassetid://1182470584"
  57. Tool0.GripForward = Vector3.new(1, -0, -1.19248806e-08)
  58. Tool0.GripRight = Vector3.new(1.19248806e-08, 0, 1)
  59. Script1.Parent = Tool0
  60. table.insert(cors,sandbox(Script1,function()
  61. -- // Created by StarWars
  62. local CollectionService = game:GetService("CollectionService")
  63. local Debris = game:GetService("Debris")
  64.  
  65. local GearService = require(1075123174)
  66.  
  67. local Tool = script.Parent
  68. local Handle = Tool.Handle
  69. local SideBlade1 = Tool.SideBlade1
  70. local SideBlade2 = Tool.SideBlade2
  71. local Blade = Tool.Blade
  72. local AnimationsFolder = Tool:WaitForChild("Animations")
  73. local R6Folder = AnimationsFolder:WaitForChild("R6")
  74. local R15Folder = AnimationsFolder:WaitForChild("R15")
  75.  
  76. if Tool:FindFirstChild("Display") then
  77. Tool.Display:Destroy()
  78. end
  79.  
  80. Handle.Transparency = 0
  81.  
  82. SideBlade1.Transparency = 1
  83. SideBlade2.Transparency = 1
  84. Blade.Transparency = 1
  85.  
  86. CollectionService:AddTag(Blade, "roblox_lightsaber_blade")
  87.  
  88. local Sounds = {
  89. Open = Handle.TurnOn,
  90. Close = Handle.TurnOff,
  91. Hum = Handle.Hum
  92. }
  93.  
  94. local HitSounds = {
  95. 1194460845,
  96. 1194461060
  97. }
  98.  
  99. local Animations =
  100. {
  101. Swing1 = {Animation = R6Folder:WaitForChild("Swing"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  102. Swing2 = {Animation = R6Folder:WaitForChild("Swing2"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  103. Swing3 = {Animation = R6Folder:WaitForChild("Swing3"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  104. }
  105.  
  106. local PossibleAnimations =
  107. {
  108. {Animation = Animations.Swing1, Audio = Handle.Swing};
  109. {Animation = Animations.Swing2, Audio = Handle.Swing2};
  110. {Animation = Animations.Swing3, Audio = Handle.Swing3};
  111. }
  112.  
  113. local Gear = GearService:BindGear(Tool)
  114. Gear:SetupRemoteFunctions()
  115. Gear:SetupLocalScript("MouseIcon")
  116.  
  117. local Remotes = Tool:WaitForChild("Remotes")
  118. local ClientControl = Remotes:WaitForChild("ClientControls")
  119.  
  120. local ToolEquipped = false
  121.  
  122. local BladeDebounce = false
  123. Blade.Touched:Connect(function(hit)
  124. if BladeDebounce then return end
  125. BladeDebounce = true
  126. if hit and CollectionService:HasTag(hit, "roblox_lightsaber_blade") then
  127. -- make ligthsaber hit sound
  128. local HitSound = Instance.new("Sound")
  129. HitSound.SoundId = "rbxassetid://" .. HitSounds[math.random(#HitSounds)]
  130. HitSound.Volume = 0.2
  131. HitSound.Parent = Handle
  132. HitSound:Play()
  133. Debris:AddItem(HitSound, 1)
  134. wait()
  135. elseif hit and hit.Parent then
  136. local Humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
  137. if Humanoid and Humanoid.Health > 0 and Humanoid ~= Gear.Humanoid then
  138. Humanoid:TakeDamage(60)
  139. wait()
  140. end
  141. end
  142. BladeDebounce = false
  143. end)
  144.  
  145. local SideBlade1Debounce = false
  146. SideBlade1.Touched:Connect(function(hit)
  147. if SideBlade1Debounce then return end
  148. SideBlade1Debounce = true
  149. if hit and CollectionService:HasTag(hit, "roblox_lightsaber_blade") then
  150. -- make ligthsaber hit sound
  151. local HitSound = Instance.new("Sound")
  152. HitSound.SoundId = "rbxassetid://" .. HitSounds[math.random(#HitSounds)]
  153. HitSound.Volume = 0.2
  154. HitSound.Parent = Handle
  155. HitSound:Play()
  156. Debris:AddItem(HitSound, 1)
  157. wait()
  158. elseif hit and hit.Parent then
  159. local Humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
  160. if Humanoid and Humanoid.Health > 0 and Humanoid ~= Gear.Humanoid then
  161. Humanoid:TakeDamage(5)
  162. wait()
  163. end
  164. end
  165. SideBlade1Debounce = false
  166. end)
  167.  
  168.  
  169. local SideBlade2Debounce = false
  170. SideBlade2.Touched:Connect(function(hit)
  171. if SideBlade2Debounce then return end
  172. SideBlade2Debounce = true
  173. if hit and CollectionService:HasTag(hit, "roblox_lightsaber_blade") then
  174. -- make ligthsaber hit sound
  175. local HitSound = Instance.new("Sound")
  176. HitSound.SoundId = "rbxassetid://" .. HitSounds[math.random(#HitSounds)]
  177. HitSound.Volume = 0.2
  178. HitSound.Parent = Handle
  179. HitSound:Play()
  180. Debris:AddItem(HitSound, 1)
  181. wait()
  182. elseif hit and hit.Parent then
  183. local Humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
  184. if Humanoid and Humanoid.Health > 0 and Humanoid ~= Gear.Humanoid then
  185. Humanoid:TakeDamage(5)
  186. wait()
  187. end
  188. end
  189. SideBlade2Debounce = false
  190. end)
  191.  
  192. Gear:BindActivateFunction("kylo_lightsaber_activate", function()
  193. -- Play swing sound
  194. local RandomSwing = PossibleAnimations[math.random(#PossibleAnimations)]
  195. pcall(function()
  196. ClientControl:InvokeClient(Gear.Player, "PlayAnimation", RandomSwing.Animation)
  197. ClientControl:InvokeClient(Gear.Player, "PlaySound", RandomSwing.Audio)
  198. end)
  199. wait(0.6)
  200. end)
  201.  
  202. Gear:BindEquippedFunction("kylo_lightsaber_equipped", function()
  203. for _, obj in next, Blade:GetChildren() do
  204. if obj and (obj:IsA("SurfaceLight") or obj:IsA("Beam")) then
  205. obj.Enabled = true
  206. end
  207. end
  208.  
  209. if Gear.Humanoid and Gear.Humanoid.RigType == Enum.HumanoidRigType.R15 then
  210. Animations =
  211. {
  212. Swing1 = {Animation = R15Folder:WaitForChild("Swing"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  213. Swing2 = {Animation = R15Folder:WaitForChild("Swing2"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  214. Swing3 = {Animation = R15Folder:WaitForChild("Swing3"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  215. }
  216.  
  217. PossibleAnimations =
  218. {
  219. {Animation = Animations.Swing1, Audio = Handle.Swing};
  220. {Animation = Animations.Swing2, Audio = Handle.Swing2};
  221. {Animation = Animations.Swing3, Audio = Handle.Swing3};
  222. }
  223. else
  224. Animations =
  225. {
  226. Swing1 = {Animation = R6Folder:WaitForChild("Swing"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  227. Swing2 = {Animation = R6Folder:WaitForChild("Swing2"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  228. Swing3 = {Animation = R6Folder:WaitForChild("Swing3"), FadeTime = nil, Weight = nil, Speed = nil, Duration = nil};
  229. }
  230.  
  231. PossibleAnimations =
  232. {
  233. {Animation = Animations.Swing1, Audio = Handle.Swing};
  234. {Animation = Animations.Swing2, Audio = Handle.Swing2};
  235. {Animation = Animations.Swing3, Audio = Handle.Swing3};
  236. }
  237. end
  238.  
  239. Blade.Transparency = 0
  240.  
  241. -- Play turn on sound
  242. ToolEquipped = true
  243. Sounds.Open:Play()
  244. delay(1.21, function()
  245. if Sounds.Open.IsPlaying and ToolEquipped then
  246. Sounds.Hum:Play()
  247. end
  248. end)
  249. delay(0.35, function()
  250. if Sounds.Open.IsPlaying and ToolEquipped then
  251. SideBlade1.Transparency = 0
  252. SideBlade2.Transparency = 0
  253. end
  254. end)
  255. end)
  256.  
  257. Gear:BindUnequippedFunction("kylo_lightsaber_unequipped", function()
  258. for _, obj in next, Blade:GetChildren() do
  259. if obj and (obj:IsA("SurfaceLight") or obj:IsA("Beam")) then
  260. obj.Enabled = false
  261. end
  262. end
  263.  
  264. ToolEquipped = false
  265.  
  266. Blade.Transparency = 1
  267. SideBlade1.Transparency = 1
  268. SideBlade2.Transparency = 1
  269.  
  270. -- Play turn off sound
  271. Sounds.Hum:Stop()
  272. Sounds.Close:Play()
  273. end)
  274.  
  275. end))
  276. Folder2.Name = "Animations"
  277. Folder2.Parent = Tool0
  278. Folder3.Name = "R15"
  279. Folder3.Parent = Folder2
  280. Animation4.Name = "Swing"
  281. Animation4.Parent = Folder3
  282. Animation4.AnimationId = "rbxassetid://1207976470"
  283. Animation5.Name = "Swing3"
  284. Animation5.Parent = Folder3
  285. Animation5.AnimationId = "rbxassetid://1207986607"
  286. Animation6.Name = "Swing2"
  287. Animation6.Parent = Folder3
  288. Animation6.AnimationId = "rbxassetid://1207983766"
  289. Folder7.Name = "R6"
  290. Folder7.Parent = Folder2
  291. Animation8.Name = "Swing"
  292. Animation8.Parent = Folder7
  293. Animation8.AnimationId = "rbxassetid://1208016813"
  294. Animation9.Name = "Swing3"
  295. Animation9.Parent = Folder7
  296. Animation9.AnimationId = "rbxassetid://1208024101"
  297. Animation10.Name = "Swing2"
  298. Animation10.Parent = Folder7
  299. Animation10.AnimationId = "rbxassetid://1208020446"
  300. Part11.Name = "Blade"
  301. Part11.Parent = Tool0
  302. Part11.Material = Enum.Material.Neon
  303. Part11.BrickColor = BrickColor.new("Salmon")
  304. Part11.Transparency = 1
  305. Part11.CanCollide = false
  306. Part11.Size = Vector3.new(0.13000001, 5, 0.170000032)
  307. Part11.CFrame = CFrame.new(-0.000259399414, 5.25934029, 0.00289916992, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  308. Part11.Color = Color3.new(0.952941, 0.537255, 0.537255)
  309. Part11.Position = Vector3.new(-0.000259399414, 5.25934029, 0.00289916992)
  310. Part11.Color = Color3.new(0.952941, 0.537255, 0.537255)
  311. CylinderMesh12.Parent = Part11
  312. SurfaceLight13.Name = "Light"
  313. SurfaceLight13.Parent = Part11
  314. SurfaceLight13.Color = Color3.new(0.960784, 0.313726, 0.184314)
  315. SurfaceLight13.Brightness = 25
  316. SurfaceLight13.Range = 5
  317. SurfaceLight13.Angle = 180
  318. SurfaceLight13.Color = Color3.new(0.960784, 0.313726, 0.184314)
  319. SurfaceLight14.Name = "Light"
  320. SurfaceLight14.Parent = Part11
  321. SurfaceLight14.Color = Color3.new(0.960784, 0.313726, 0.184314)
  322. SurfaceLight14.Brightness = 25
  323. SurfaceLight14.Range = 5
  324. SurfaceLight14.Angle = 180
  325. SurfaceLight14.Face = Enum.NormalId.Right
  326. SurfaceLight14.Color = Color3.new(0.960784, 0.313726, 0.184314)
  327. SurfaceLight15.Name = "Light"
  328. SurfaceLight15.Parent = Part11
  329. SurfaceLight15.Color = Color3.new(0.960784, 0.313726, 0.184314)
  330. SurfaceLight15.Brightness = 25
  331. SurfaceLight15.Range = 5
  332. SurfaceLight15.Angle = 180
  333. SurfaceLight15.Face = Enum.NormalId.Left
  334. SurfaceLight15.Color = Color3.new(0.960784, 0.313726, 0.184314)
  335. SurfaceLight16.Name = "Light"
  336. SurfaceLight16.Parent = Part11
  337. SurfaceLight16.Color = Color3.new(0.960784, 0.313726, 0.184314)
  338. SurfaceLight16.Brightness = 25
  339. SurfaceLight16.Range = 5
  340. SurfaceLight16.Angle = 180
  341. SurfaceLight16.Face = Enum.NormalId.Back
  342. SurfaceLight16.Color = Color3.new(0.960784, 0.313726, 0.184314)
  343. SurfaceLight17.Name = "Light"
  344. SurfaceLight17.Parent = Part11
  345. SurfaceLight17.Color = Color3.new(0.960784, 0.313726, 0.184314)
  346. SurfaceLight17.Brightness = 25
  347. SurfaceLight17.Range = 5
  348. SurfaceLight17.Angle = 180
  349. SurfaceLight17.Face = Enum.NormalId.Top
  350. SurfaceLight17.Color = Color3.new(0.960784, 0.313726, 0.184314)
  351. SurfaceLight18.Name = "Light"
  352. SurfaceLight18.Parent = Part11
  353. SurfaceLight18.Color = Color3.new(0.960784, 0.313726, 0.184314)
  354. SurfaceLight18.Brightness = 25
  355. SurfaceLight18.Range = 5
  356. SurfaceLight18.Angle = 180
  357. SurfaceLight18.Face = Enum.NormalId.Bottom
  358. SurfaceLight18.Color = Color3.new(0.960784, 0.313726, 0.184314)
  359. Attachment19.Name = "Attachment1"
  360. Attachment19.Parent = Part11
  361. Attachment19.CFrame = CFrame.new(0, 2.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  362. Attachment19.Position = Vector3.new(0, 2.5, 0)
  363. Attachment20.Name = "Attachment0"
  364. Attachment20.Parent = Part11
  365. Attachment20.CFrame = CFrame.new(0, -2.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  366. Attachment20.Position = Vector3.new(0, -2.5, 0)
  367. Script21.Name = "BreakJointsScript"
  368. Script21.Parent = Part11
  369. table.insert(cors,sandbox(Script21,function()
  370. function onTouched(hit)
  371. hit:BreakJoints()
  372. end
  373.  
  374. connection = script.Parent.Touched:connect(onTouched)
  375. end))
  376. Part22.Name = "SideBlade1"
  377. Part22.Parent = Tool0
  378. Part22.Material = Enum.Material.Neon
  379. Part22.BrickColor = BrickColor.new("Salmon")
  380. Part22.Transparency = 1
  381. Part22.Rotation = Vector3.new(-90, 0, 90)
  382. Part22.CanCollide = false
  383. Part22.Size = Vector3.new(0.13000001, 0.5, 0.170000032)
  384. Part22.CFrame = CFrame.new(-0.628036499, 2.47327375, 0.00289916992, 0, -1, 0, 0, 0, 1, -1, 0, 0)
  385. Part22.Color = Color3.new(0.952941, 0.537255, 0.537255)
  386. Part22.Position = Vector3.new(-0.628036499, 2.47327375, 0.00289916992)
  387. Part22.Orientation = Vector3.new(-90, 90, 0)
  388. Part22.Color = Color3.new(0.952941, 0.537255, 0.537255)
  389. CylinderMesh23.Parent = Part22
  390. Part24.Name = "SideBlade2"
  391. Part24.Parent = Tool0
  392. Part24.Material = Enum.Material.Neon
  393. Part24.BrickColor = BrickColor.new("Salmon")
  394. Part24.Transparency = 1
  395. Part24.Rotation = Vector3.new(-180, 0, -90)
  396. Part24.CanCollide = false
  397. Part24.Size = Vector3.new(0.13000001, 0.5, 0.170000032)
  398. Part24.CFrame = CFrame.new(0.616630554, 2.47327399, 0.00289916992, 0, 1, 0, 1, 0, 0, 0, 0, -1)
  399. Part24.Color = Color3.new(0.952941, 0.537255, 0.537255)
  400. Part24.Position = Vector3.new(0.616630554, 2.47327399, 0.00289916992)
  401. Part24.Orientation = Vector3.new(0, 180, 90)
  402. Part24.Color = Color3.new(0.952941, 0.537255, 0.537255)
  403. CylinderMesh25.Parent = Part24
  404. Script26.Name = "qPerfectionWeld"
  405. Script26.Parent = Tool0
  406. table.insert(cors,sandbox(Script26,function()
  407. -- Created by Quenty (@Quenty, follow me on twitter).
  408. -- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
  409. -- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
  410.  
  411. --[[ INSTRUCTIONS
  412. - Place in the model
  413. - Make sure model is anchored
  414. - That's it. It will weld the model and all children.
  415.  
  416. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  417. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  418. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  419. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  420. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  421. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  422. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  423. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  424.  
  425. 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.
  426. ]]
  427.  
  428. --[[ DOCUMENTATION
  429. - 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.
  430. - Will work in PBS servers
  431. - Will work as long as it starts out with the part anchored
  432. - Stores the relative CFrame as a CFrame value
  433. - Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
  434. - Utilizes a recursive algorith to find all parts in the model
  435. - Will reweld on script reparent if the script is initially parented to a tool.
  436. - Welds as fast as possible
  437. ]]
  438.  
  439. -- qPerfectionWeld.lua
  440. -- Created 10/6/2014
  441. -- Author: Quenty
  442. -- Version 1.0.3
  443.  
  444. -- Updated 10/14/2014 - Updated to 1.0.1
  445. --- Bug fix with existing ROBLOX welds ? Repro by asimo3089
  446.  
  447. -- Updated 10/14/2014 - Updated to 1.0.2
  448. --- Fixed bug fix.
  449.  
  450. -- Updated 10/14/2014 - Updated to 1.0.3
  451. --- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
  452.  
  453. 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).
  454.  
  455.  
  456. local function CallOnChildren(Instance, FunctionToCall)
  457. -- Calls a function on each of the children of a certain object, using recursion.
  458.  
  459. FunctionToCall(Instance)
  460.  
  461. for _, Child in next, Instance:GetChildren() do
  462. CallOnChildren(Child, FunctionToCall)
  463. end
  464. end
  465.  
  466. local function GetNearestParent(Instance, ClassName)
  467. -- Returns the nearest parent of a certain class, or returns nil
  468.  
  469. local Ancestor = Instance
  470. repeat
  471. Ancestor = Ancestor.Parent
  472. if Ancestor == nil then
  473. return nil
  474. end
  475. until Ancestor:IsA(ClassName)
  476.  
  477. return Ancestor
  478. end
  479.  
  480. local function GetBricks(StartInstance)
  481. local List = {}
  482.  
  483. -- if StartInstance:IsA("BasePart") then
  484. -- List[#List+1] = StartInstance
  485. -- end
  486.  
  487. CallOnChildren(StartInstance, function(Item)
  488. if Item:IsA("BasePart") then
  489. List[#List+1] = Item;
  490. end
  491. end)
  492.  
  493. return List
  494. end
  495.  
  496. local function Modify(Instance, Values)
  497. -- Modifies an Instance by using a table.
  498.  
  499. assert(type(Values) == "table", "Values is not a table");
  500.  
  501. for Index, Value in next, Values do
  502. if type(Index) == "number" then
  503. Value.Parent = Instance
  504. else
  505. Instance[Index] = Value
  506. end
  507. end
  508. return Instance
  509. end
  510.  
  511. local function Make(ClassType, Properties)
  512. -- Using a syntax hack to create a nice way to Make new items.
  513.  
  514. return Modify(Instance.new(ClassType), Properties)
  515. end
  516.  
  517. local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
  518. local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
  519.  
  520. local function HasWheelJoint(Part)
  521. for _, SurfaceName in pairs(Surfaces) do
  522. for _, HingSurfaceName in pairs(HingSurfaces) do
  523. if Part[SurfaceName].Name == HingSurfaceName then
  524. return true
  525. end
  526. end
  527. end
  528.  
  529. return false
  530. end
  531.  
  532. local function ShouldBreakJoints(Part)
  533. --- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
  534. -- definitely some edge cases.
  535.  
  536. if NEVER_BREAK_JOINTS then
  537. return false
  538. end
  539.  
  540. if HasWheelJoint(Part) then
  541. return false
  542. end
  543.  
  544. local Connected = Part:GetConnectedParts()
  545.  
  546. if #Connected == 1 then
  547. return false
  548. end
  549.  
  550. for _, Item in pairs(Connected) do
  551. if HasWheelJoint(Item) then
  552. return false
  553. elseif not Item:IsDescendantOf(script.Parent) then
  554. return false
  555. end
  556. end
  557.  
  558. return true
  559. end
  560.  
  561. local function WeldTogether(Part0, Part1, JointType, WeldParent)
  562. --- Weld's 2 parts together
  563. -- @param Part0 The first part
  564. -- @param Part1 The second part (Dependent part most of the time).
  565. -- @param [JointType] The type of joint. Defaults to weld.
  566. -- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
  567. -- @return The weld created.
  568.  
  569. JointType = JointType or "Weld"
  570. local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
  571.  
  572. local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
  573. Modify(NewWeld, {
  574. Name = "qCFrameWeldThingy";
  575. Part0 = Part0;
  576. Part1 = Part1;
  577. C0 = CFrame.new();--Part0.CFrame:inverse();
  578. C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
  579. Parent = Part1;
  580. })
  581.  
  582. if not RelativeValue then
  583. RelativeValue = Make("CFrameValue", {
  584. Parent = Part1;
  585. Name = "qRelativeCFrameWeldValue";
  586. Archivable = true;
  587. Value = NewWeld.C1;
  588. })
  589. end
  590.  
  591. return NewWeld
  592. end
  593.  
  594. local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
  595. -- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
  596. -- @param MainPart The part to weld the model to (can be in the model).
  597. -- @param [JointType] The type of joint. Defaults to weld.
  598. -- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
  599.  
  600. for _, Part in pairs(Parts) do
  601. if ShouldBreakJoints(Part) then
  602. Part:BreakJoints()
  603. end
  604. end
  605.  
  606. for _, Part in pairs(Parts) do
  607. if Part ~= MainPart then
  608. WeldTogether(MainPart, Part, JointType, MainPart)
  609. end
  610. end
  611.  
  612. if not DoNotUnanchor then
  613. for _, Part in pairs(Parts) do
  614. Part.Anchored = false
  615. end
  616. MainPart.Anchored = false
  617. end
  618. end
  619.  
  620. local function PerfectionWeld()
  621. local Tool = GetNearestParent(script, "Tool")
  622.  
  623. local Parts = GetBricks(script.Parent)
  624. 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]
  625.  
  626. if PrimaryPart then
  627. WeldParts(Parts, PrimaryPart, "Weld", false)
  628. else
  629. warn("qWeld - Unable to weld part")
  630. end
  631.  
  632. return Tool
  633. end
  634.  
  635. local Tool = PerfectionWeld()
  636.  
  637.  
  638. if Tool and script.ClassName == "Script" then
  639. --- Don't bother with local scripts
  640.  
  641. script.Parent.AncestryChanged:connect(function()
  642. PerfectionWeld()
  643. end)
  644. end
  645.  
  646. -- Created by Quenty (@Quenty, follow me on twitter).
  647.  
  648. end))
  649. Part27.Name = "Handle"
  650. Part27.Parent = Tool0
  651. Part27.Material = Enum.Material.Neon
  652. Part27.BrickColor = BrickColor.new("Really black")
  653. Part27.Transparency = 1
  654. Part27.CanCollide = false
  655. Part27.Size = Vector3.new(0.200000182, 0.0500000454, 0.100000091)
  656. Part27.CFrame = CFrame.new(0, 1.88900006, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  657. Part27.BottomSurface = Enum.SurfaceType.Smooth
  658. Part27.TopSurface = Enum.SurfaceType.Smooth
  659. Part27.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  660. Part27.Position = Vector3.new(0, 1.88900006, 0)
  661. Part27.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  662. SpecialMesh28.Parent = Part27
  663. SpecialMesh28.MeshId = "rbxassetid://1194607638"
  664. SpecialMesh28.TextureId = "rbxassetid://1182470870"
  665. SpecialMesh28.MeshType = Enum.MeshType.FileMesh
  666. Attachment29.Name = "RightGripAttachment"
  667. Attachment29.Parent = Part27
  668. Motor6D30.Name = "Blade"
  669. Motor6D30.Parent = Part27
  670. Motor6D30.C1 = CFrame.new(0.000259399414, -3.40332127, -0.00291442871, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  671. Motor6D30.Part0 = nil
  672. Motor6D30.Part1 = nil
  673. Sound31.Name = "TurnOn"
  674. Sound31.Parent = Part27
  675. Sound31.SoundId = "rbxassetid://1207779690"
  676. Sound32.Name = "TurnOff"
  677. Sound32.Parent = Part27
  678. Sound32.SoundId = "rbxassetid://1207779220"
  679. Sound33.Name = "Swing3"
  680. Sound33.Parent = Part27
  681. Sound33.SoundId = "rbxassetid://1208051533"
  682. Sound34.Name = "Swing2"
  683. Sound34.Parent = Part27
  684. Sound34.SoundId = "rbxassetid://1208051397"
  685. Sound35.Name = "Swing"
  686. Sound35.Parent = Part27
  687. Sound35.SoundId = "rbxassetid://1207802606"
  688. Sound36.Name = "Hum"
  689. Sound36.Parent = Part27
  690. Sound36.SoundId = "rbxassetid://1207779441"
  691. Sound36.Looped = true
  692. for i,v in pairs(mas:GetChildren()) do
  693. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  694. pcall(function() v:MakeJoints() end)
  695. end
  696. mas:Destroy()
  697. for i,v in pairs(cors) do
  698. spawn(function()
  699. pcall(v)
  700. end)
  701. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement