Advertisement
Guest User

asdsasdsasd

a guest
Jan 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.11 KB | None | 0 0
  1. Hi
  2.  
  3.  
  4. --[[
  5. Script Version 1.0
  6. Changelog Revision 1
  7.  
  8. A chaninsaw.
  9. Script by DarkShadow6
  10.  
  11. Changelog:
  12. o 1.0
  13. o Final tweaks to the script / model.
  14. o Kept the basic animations... For now.
  15. o 0.9
  16. o Added a model... Eww.
  17. o 0.2 - 0.8
  18. o Changes to script
  19. o 0.1
  20. o Copied the Combat Knife.
  21. o Basic sounds.
  22. o Basic animations.
  23. --]]
  24.  
  25.  
  26. if script == nil then return end
  27.  
  28.  
  29. Player = game.Players.LocalPlayer
  30. Char = Player.Character
  31. animate = Char:findFirstChild("Animate")
  32. if animate then
  33. animate:remove()
  34. end
  35. Name = "Chainsaw"
  36. selected = false
  37. Button1Down = false
  38. damage = 10
  39. canUse = true
  40. activated = false
  41. swordType = "normal"
  42.  
  43.  
  44. animation = {}
  45. animation["slashing"] = nil
  46.  
  47.  
  48. function makeParts(format)
  49. local model = Instance.new("Model")
  50. model.Name = Name
  51. model.Parent = Player.Character
  52. local pm2 = Instance.new("Part")
  53. pm2.Name = "Weld Point"
  54. pm2.FormFactor = "Custom"
  55. pm2.Size = Vector3.new(1, 1, 1)
  56. pm2.BrickColor = BrickColor.new("Really black")
  57. pm2.Transparency = 1
  58. pm2.Locked = true
  59. pm2.TopSurface = 0
  60. pm2.BottomSurface = 0
  61. pm2.Parent = model
  62. if format ~= nil then
  63. local w = Instance.new("Weld")
  64. w.Part0 = pm2
  65. if format == "hand" then
  66. w.Part1 = Player.Character:FindFirstChild("Right Arm")
  67. w.C0 = CFrame.new(0, 1.1, 0.3)
  68. w.C1 = CFrame.new()
  69. w.Parent = pm2
  70. elseif format == "holster" then
  71. w.Part1 = Player.Character:FindFirstChild("Torso")
  72. w.C0 = CFrame.new(-0.9, -0.5, -0.8) * CFrame.fromEulerAnglesXYZ(math.rad(90), math.rad(90), 0)
  73. w.C1 = CFrame.new()
  74. w.Parent = pm2
  75. model.Name = Name.. " (Holstered)"
  76. else
  77. print("Error: Incorrect format string!")
  78. end
  79. end
  80. local pm = Instance.new("Part")
  81. pm.Name = "Handle"
  82. pm.FormFactor = "Custom"
  83. pm.Size = Vector3.new(1, 1, 1)
  84. pm.BrickColor = BrickColor.new("Bright orange")
  85. pm.Reflectance = 0.025
  86. pm.Locked = true
  87. pm.TopSurface = 0
  88. pm.BottomSurface = 0
  89. pm.Parent = model
  90. local m = Instance.new("SpecialMesh")
  91. m.MeshType = "Brick"
  92. m.Scale = Vector3.new(0.6, 0.9, 1)
  93. m.Parent = pm
  94. local w = Instance.new("Weld")
  95. w.Part0 = pm
  96. w.Part1 = pm2
  97. w.C0 = CFrame.new()
  98. w.C1 = CFrame.new()
  99. w.Parent = pm
  100. local s = Instance.new("Sound")
  101. s.Name = "Start"
  102. s.SoundId = "http://www.roblox.com/Asset/?id=2766589"
  103. s.Volume = 1
  104. s.Pitch = 2
  105. s.Looped = false
  106. s.Parent = pm
  107. local s = Instance.new("Sound")
  108. s.Name = "Saw"
  109. s.SoundId = "http://www.roblox.com/Asset/?id=2766576"
  110. s.Volume = 1
  111. s.Pitch = 0.25
  112. s.Looped = true
  113. s.Parent = pm
  114. local p = Instance.new("Part")
  115. p.Name = "Back"
  116. p.FormFactor = "Custom"
  117. p.Size = Vector3.new(1, 1, 1)
  118. p.BrickColor = BrickColor.new("Bright orange")
  119. p.Reflectance = 0.025
  120. p.Locked = true
  121. p.TopSurface = 0
  122. p.BottomSurface = 0
  123. p.Parent = model
  124. local m = Instance.new("SpecialMesh")
  125. m.MeshType = "Wedge"
  126. m.Scale = Vector3.new(0.6, 0.8, 0.9)
  127. m.Parent = p
  128. local w = Instance.new("Weld")
  129. w.Part0 = p
  130. w.Part1 = pm
  131. w.C0 = CFrame.new(0, -0.9, 0) * CFrame.fromEulerAnglesXYZ(math.rad(270), 0, 0)
  132. w.C1 = CFrame.new()
  133. w.Parent = p
  134. local p = Instance.new("Part")
  135. p.Name = "Blade"
  136. p.FormFactor = "Custom"
  137. p.Size = Vector3.new(1, 1, 3)
  138. p.CanCollide = false
  139. p.BrickColor = BrickColor.new("Institutional white")
  140. p.Reflectance = 0.2
  141. p.Locked = true
  142. p.TopSurface = 0
  143. p.BottomSurface = 0
  144. p.Parent = model
  145. local m = Instance.new("SpecialMesh")
  146. m.MeshType = "Brick"
  147. m.Scale = Vector3.new(0.03, 0.7, 0.9)
  148. m.Parent = p
  149. local w = Instance.new("Weld")
  150. w.Part0 = p
  151. w.Part1 = pm
  152. w.C0 = CFrame.new(0, 0.075, 1.85)
  153. w.C1 = CFrame.new()
  154. w.Parent = p
  155. p.Touched:connect(function(hit) onTouched(hit, p, "sword") end)
  156. local p = Instance.new("Part")
  157. p.Name = "Blade Tip"
  158. p.FormFactor = "Custom"
  159. p.Size = Vector3.new(1, 1, 1)
  160. p.CanCollide = false
  161. p.BrickColor = BrickColor.new("Institutional white")
  162. p.Reflectance = 0.2
  163. p.Locked = true
  164. p.TopSurface = 0
  165. p.BottomSurface = 0
  166. p.Parent = model
  167. local m = Instance.new("CylinderMesh")
  168. m.Scale = Vector3.new(0.7, 0.03, 0.7)
  169. m.Parent = p
  170. local w = Instance.new("Weld")
  171. w.Part0 = p
  172. w.Part1 = pm
  173. w.C0 = CFrame.new(-0.075, 0, 3.2) * CFrame.fromEulerAnglesXYZ(0, 0, math.rad(90))
  174. w.C1 = CFrame.new()
  175. w.Parent = p
  176. p.Touched:connect(function(hit) onTouched(hit, p, "sword") end)
  177. end
  178.  
  179.  
  180. function removeParts(format)
  181. if format == "hand" then
  182. if Player.Character:FindFirstChild(Name) ~= nil then
  183. Player.Character[Name]:Remove()
  184. end
  185. elseif format == "holster" then
  186. if Player.Character:FindFirstChild(Name.. " (Holstered)") ~= nil then
  187. Player.Character[Name.. " (Holstered)"]:Remove()
  188. end
  189. end
  190. end
  191.  
  192.  
  193. function onTouched(hit, source, format)
  194. if format == "sword" then
  195. if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent ~= Player.Character then
  196. tagHumanoid(hit.Parent.Humanoid)
  197. if swordType == "normal" then
  198. hit.Parent.Humanoid:TakeDamage(1)
  199. elseif swordType == "slash" then
  200. hit.Parent.Humanoid:TakeDamage(damage)
  201. end
  202. delay(3, function() untagHumanoid(hit.Parent.Humanoid) end)
  203. end
  204. end
  205. end
  206.  
  207.  
  208. function SetAngle(Joint, Angle, Character)
  209. if Character == nil then return false end
  210. local Joints = {
  211. Character.Torso:FindFirstChild("Right Shoulder 2"),
  212. Character.Torso:FindFirstChild("Left Shoulder 2"),
  213. Character.Torso:FindFirstChild("Right Hip 2"),
  214. Character.Torso:FindFirstChild("Left Hip 2")
  215. }
  216. if Joints[Joint] == nil then return false end
  217. if Joint == 1 or Joint == 3 then
  218. Joints[Joint].DesiredAngle = Angle
  219. end
  220. if Joint == 2 or Joint == 4 then
  221. Joints[Joint].DesiredAngle = -Angle
  222. end
  223. end
  224.  
  225.  
  226. function ForceAngle(Joint, Angle, Character)
  227. if Character == nil then return false end
  228. local Joints = {
  229. Character.Torso:FindFirstChild("Right Shoulder 2"),
  230. Character.Torso:FindFirstChild("Left Shoulder 2"),
  231. Character.Torso:FindFirstChild("Right Hip 2"),
  232. Character.Torso:FindFirstChild("Left Hip 2")
  233. }
  234. if Joints[Joint] == nil then return false end
  235. if Joint == 1 or Joint == 3 then
  236. Joints[Joint].DesiredAngle = Angle
  237. Joints[Joint].CurrentAngle = Angle
  238. end
  239. if Joint == 2 or Joint == 4 then
  240. Joints[Joint].DesiredAngle = -Angle
  241. Joints[Joint].CurrentAngle = -Angle
  242. end
  243. end
  244.  
  245.  
  246. function SetSpeed(Joint, Speed, Character)
  247. if Character == nil then return false end
  248. local Joints = {
  249. Character.Torso:FindFirstChild("Right Shoulder 2"),
  250. Character.Torso:FindFirstChild("Left Shoulder 2"),
  251. Character.Torso:FindFirstChild("Right Hip 2"),
  252. Character.Torso:FindFirstChild("Left Hip 2")
  253. }
  254. if Joints[Joint] == nil then return false end
  255. Joints[Joint].MaxVelocity = Speed
  256. end
  257.  
  258.  
  259. function DisableLimb(Limb, Character)
  260. if Character == nil then return false end
  261. if Character:FindFirstChild("Torso") == nil then return false end
  262. local Joints = {
  263. Character.Torso:FindFirstChild("Right Shoulder"),
  264. Character.Torso:FindFirstChild("Left Shoulder"),
  265. Character.Torso:FindFirstChild("Right Hip"),
  266. Character.Torso:FindFirstChild("Left Hip")
  267. }
  268. local Limbs = {
  269. Character:FindFirstChild("Right Arm"),
  270. Character:FindFirstChild("Left Arm"),
  271. Character:FindFirstChild("Right Leg"),
  272. Character:FindFirstChild("Left Leg")
  273. }
  274. if Joints[Limb] == nil then return false end
  275. if Limbs[Limb] == nil then return false end
  276. local Joint = Instance.new("Motor")
  277. Joint.Parent = Character.Torso
  278. Joint.Part0 = Character.Torso
  279. Joint.Part1 = Limbs[Limb]
  280. if Limb == 1 then
  281. Joint.C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  282. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  283. Joint.Name = "Right Shoulder 2"
  284. elseif Limb == 2 then
  285. Joint.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  286. Joint.C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  287. Joint.Name = "Left Shoulder 2"
  288. elseif Limb == 3 then
  289. Joint.C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  290. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  291. Joint.Name = "Right Hip 2"
  292. elseif Limb == 4 then
  293. Joint.C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  294. Joint.C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  295. Joint.Name = "Left Hip 2"
  296. end
  297. Joint.MaxVelocity = Joints[Limb].MaxVelocity
  298. Joint.CurrentAngle = Joints[Limb].CurrentAngle
  299. Joint.DesiredAngle = Joints[Limb].DesiredAngle
  300. Joints[Limb]:Remove()
  301. end
  302.  
  303.  
  304. function ResetLimbCFrame(Limb, Character)
  305. if Character == nil then return false end
  306. if Character.Parent == nil then return false end
  307. if Character:FindFirstChild("Torso") == nil then return false end
  308. local Joints = {
  309. Character.Torso:FindFirstChild("Right Shoulder 2"),
  310. Character.Torso:FindFirstChild("Left Shoulder 2"),
  311. Character.Torso:FindFirstChild("Right Hip 2"),
  312. Character.Torso:FindFirstChild("Left Hip 2")
  313. }
  314. local Limbs = {
  315. Character:FindFirstChild("Right Arm"),
  316. Character:FindFirstChild("Left Arm"),
  317. Character:FindFirstChild("Right Leg"),
  318. Character:FindFirstChild("Left Leg")
  319. }
  320. if Joints[Limb] == nil then return false end
  321. if Limbs[Limb] == nil then return false end
  322. if Limb == 1 then
  323. Joints[Limb].C0 = CFrame.new(1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  324. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  325. elseif Limb == 2 then
  326. Joints[Limb].C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  327. Joints[Limb].C1 = CFrame.new(0, 0.5, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  328. elseif Limb == 3 then
  329. Joints[Limb].C0 = CFrame.new(0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  330. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(90), 0)
  331. elseif Limb == 4 then
  332. Joints[Limb].C0 = CFrame.new(-0.5, -1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  333. Joints[Limb].C1 = CFrame.new(0, 1, 0) * CFrame.fromEulerAnglesXYZ(0, math.rad(-90), 0)
  334. end
  335. end
  336.  
  337.  
  338. function EnableLimb(Limb, Character)
  339. if Character == nil then return false end
  340. if Character:FindFirstChild("Torso") == nil then return false end
  341. local Joints = {
  342. Character.Torso:FindFirstChild("Right Shoulder 2"),
  343. Character.Torso:FindFirstChild("Left Shoulder 2"),
  344. Character.Torso:FindFirstChild("Right Hip 2"),
  345. Character.Torso:FindFirstChild("Left Hip 2")
  346. }
  347. local Limbs = {
  348. Character:FindFirstChild("Right Arm"),
  349. Character:FindFirstChild("Left Arm"),
  350. Character:FindFirstChild("Right Leg"),
  351. Character:FindFirstChild("Left Leg")
  352. }
  353. if Joints[Limb] == nil then return false end
  354. if Limbs[Limb] == nil then return false end
  355. if Limb == 1 then
  356. Joints[Limb].Name = "Right Shoulder"
  357. elseif Limb == 2 then
  358. Joints[Limb].Name = "Left Shoulder"
  359. elseif Limb == 3 then
  360. Joints[Limb].Name = "Right Hip"
  361. elseif Limb == 4 then
  362. Joints[Limb].Name = "Left Hip"
  363. end
  364. Animate = Character:FindFirstChild("Animate")
  365. if Animate == nil then return false end
  366. Animate = Animate:Clone()
  367. Character.Animate:Remove()
  368. Animate.Parent = Character
  369. end
  370.  
  371.  
  372. function playAnimation(format, mouse)
  373. if format == "normal" then
  374. SetSpeed(1, 0.2, Player.Character)
  375. SetAngle(1, math.rad(90), Player.Character)
  376. end
  377. if format == "slashStart" then
  378. SetSpeed(1, 0.5, Player.Character)
  379. SetAngle(1, math.rad(10), Player.Character)
  380. wait(0.05)
  381. animation["slashing"] = true
  382. while animation["slashing"] == true do
  383. SetSpeed(1, 0.075, Player.Character)
  384. SetAngle(1, math.rad(math.random(10, 45)), Player.Character)
  385. Player.Character[Name].Handle.Weld.C0 = CFrame.new(0, 0, 0) * CFrame.fromEulerAnglesXYZ(math.rad(math.random(-30, 30)), 0, 0)
  386. wait(math.random(5, 10) / 100)
  387. end
  388. end
  389. if format == "slashEnd" then
  390. animation["slashing"] = false
  391. SetSpeed(1, 0.5, Player.Character)
  392. SetAngle(1, math.rad(90), Player.Character)
  393. Player.Character[Name].Handle.Weld.C0 = CFrame.new()
  394. end
  395. end
  396.  
  397.  
  398. function Weld(x, y)
  399. local weld = Instance.new("Weld")
  400. weld.Part0 = x
  401. weld.Part1 = y
  402. CJ = CFrame.new(x.Position)
  403. C0 = x.CFrame:inverse() * CJ
  404. C1 = y.CFrame:inverse() * CJ
  405. weld.C0 = C0
  406. weld.C1 = C1
  407. weld.Parent = x
  408. end
  409.  
  410.  
  411. function tagHumanoid(humanoid)
  412. local tag = Instance.new("ObjectValue")
  413. tag.Name = "creator"
  414. tag.Value = Player
  415. tag.Parent = humanoid
  416. local tag = Instance.new("StringValue")
  417. tag.Name = "creatorType1"
  418. tag.Value = Name
  419. tag.Parent = humanoid
  420. local tag = Instance.new("StringValue")
  421. tag.Name = "creatorType2"
  422. tag.Value = "cut into pieces"
  423. tag.Parent = humanoid
  424. end
  425.  
  426.  
  427. function untagHumanoid(humanoid)
  428. if humanoid ~= nil then
  429. local tag = humanoid:FindFirstChild("creator")
  430. if tag ~= nil then
  431. tag:Remove()
  432. end
  433. local tag = humanoid:FindFirstChild("creatorType1")
  434. if tag ~= nil then
  435. tag:Remove()
  436. end
  437. local tag = humanoid:FindFirstChild("creatorType2")
  438. if tag ~= nil then
  439. tag:Remove()
  440. end
  441. end
  442. end
  443.  
  444.  
  445. function onButton1Down(mouse)
  446. if selected == false then return end
  447. if Player.Character:FindFirstChild(Name) ~= nil and Button1Down == false and canUse == true and activated == true then
  448. if Player.Character[Name]:FindFirstChild("Handle") == nil then return end
  449. mouse.Icon = "rbxassetUndecided/textures\\GunWaitCursor.png"
  450. Button1Down = true
  451. canUse = false
  452. coroutine.resume(coroutine.create(function() playAnimation("slashStart") end))
  453. for i = 0.25, 1, 0.1 do
  454. Player.Character[Name].Handle.Saw.Pitch = i
  455. wait()
  456. end
  457. swordType = "slash"
  458. canUse = true
  459. end
  460. end
  461.  
  462.  
  463. function onButton1Up(mouse)
  464. if selected == false or Button1Down == false then return end
  465. Button1Down = false
  466. while canUse == false do wait() end
  467. canUse = false
  468. coroutine.resume(coroutine.create(function() playAnimation("slashEnd") end))
  469. for i = 1, 0.25, -0.05 do
  470. Player.Character[Name].Handle.Saw.Pitch = i
  471. wait()
  472. end
  473. Player.Character[Name].Handle.Saw.Pitch = 0.25
  474. swordType = "normal"
  475. mouse.Icon = "rbxassetUndecided/textures\\GunCursor.png"
  476. canUse = true
  477. end
  478.  
  479.  
  480. function onKeyDown(key, mouse)
  481. if selected == false then return end
  482. key = key:lower()
  483. if key == "q" and Button1Down == false and canUse == true then
  484. if mouse.Target == nil then return end
  485. if game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent) ~= nil then
  486. onDeselected(mouse)
  487. removeParts("holster")
  488. script.Parent.Parent = game:GetService("Players"):GetPlayerFromCharacter(mouse.Target.Parent).Backpack
  489. end
  490. end
  491. if key == "e" and Button1Down == false and canUse == true then
  492. if activated == true then
  493. canUse = false
  494. for i = 1, 0, -0.05 do
  495. Player.Character[Name].Handle.Saw.Volume = i
  496. Player.Character[Name].Handle.Saw.Pitch = Player.Character[Name].Handle.Saw.Pitch / 1.05
  497. wait()
  498. end
  499. Player.Character[Name].Handle.Saw:Stop()
  500. Player.Character[Name].Handle.Start.Pitch = 1
  501. Player.Character[Name].Handle.Start.Volume = 1
  502. Player.Character[Name].Handle.StartTonguelay()
  503. activated = false
  504. wait(0.3)
  505. canUse = true
  506. elseif activated == false then
  507. canUse = false
  508. Player.Character[Name].Handle.Start.Volume = 1
  509. Player.Character[Name].Handle.Start.Pitch = 1
  510. Player.Character[Name].Handle.StartTonguelay()
  511. wait(0.2)
  512. activated = true
  513. Player.Character[Name].Handle.SawTonguelay()
  514. for i = 0, 1, 0.05 do
  515. Player.Character[Name].Handle.Saw.Volume = i
  516. Player.Character[Name].Handle.Saw.Pitch = i / 4
  517. wait()
  518. end
  519. Player.Character[Name].Handle.Saw.Volume = 1
  520. Player.Character[Name].Handle.Saw.Pitch = 0.25
  521. canUse = true
  522. end
  523. end
  524. if key == "r" and Button1Down == false and canUse == true and activated == true then
  525. canUse = false
  526. Player.Character[Name].Handle.Start.Pitch = math.random(9, 15) / 10
  527. Player.Character[Name].Handle.Start.Volume = 1
  528. Player.Character[Name].Handle.StartTonguelay()
  529. for i = 0, 1.5, 0.1 do
  530. Player.Character[Name].Handle.Saw.Pitch = (math.sin(i) / 1.25) + 0.25
  531. wait()
  532. end
  533. for i = 1.5, 3.1, 0.05 do
  534. Player.Character[Name].Handle.Saw.Pitch = (math.sin(i) / 1.25) + 0.25
  535. wait()
  536. end
  537. Player.Character[Name].Handle.Saw.Pitch = 0.25
  538. canUse = true
  539. end
  540. if key == "t" and Button1Down == false and canUse == true and activated == true then
  541. canUse = false
  542. Player.Character[Name].Handle.Start.Pitch = math.random(9, 15) / 10
  543. Player.Character[Name].Handle.Start.Volume = 1
  544. Player.Character[Name].Handle.StartTonguelay()
  545. wait(0.2)
  546. canUse = true
  547. end
  548. end
  549.  
  550.  
  551. function onSelected(mouse)
  552. if selected == true then return end
  553. selected = true
  554. mouse.Icon = "rbxassetUndecided/textures\\GunWaitCursor.png"
  555. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  556. if Player.Character.WeaponActivated.Value == nil then break end
  557. if Player.Character.WeaponActivated.Value.Parent == nil then break end
  558. wait()
  559. end
  560. mouse.Icon = "rbxassetUndecided/textures\\GunCursor.png"
  561. local weapon = Instance.new("ObjectValue")
  562. weapon.Name = "WeaponActivated"
  563. weapon.Value = script.Parent
  564. weapon.Parent = Player.Character
  565. DisableLimb(1, Player.Character)
  566. removeParts("holster")
  567. makeParts("hand")
  568. playAnimation("normal")
  569. mouse.Button1Down:connect(function() onButton1Down(mouse) end)
  570. mouse.Button1Up:connect(function() onButton1Up(mouse) end)
  571. mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
  572. if connection ~= nil then connection:disconnect() end
  573. connection = Player.Character.Humanoid.Died:connect(function() canUse = true onDeselected(mouse) end)
  574. end
  575.  
  576.  
  577. function onDeselected(mouse)
  578. if selected == false then return end
  579. if Button1Down == true then
  580. coroutine.resume(coroutine.create(function() playAnimation("slashEnd") end))
  581. for i = 1, 0.25, -0.05 do
  582. Player.Character[Name].Handle.Saw.Pitch = i
  583. wait()
  584. end
  585. Player.Character[Name].Handle.Saw.Pitch = 0.25
  586. Button1Down = false
  587. end
  588. if activated == true then onKeyDown("e", mouse) end
  589. selected = false
  590. while canUse == false do
  591. wait()
  592. end
  593. if Player.Character:FindFirstChild("WeaponActivated") ~= nil then
  594. if Player.Character.WeaponActivated.Value == script.Parent then
  595. Player.Character.WeaponActivated:Remove()
  596. end
  597. end
  598. while Player.Character:FindFirstChild("WeaponActivated") ~= nil do
  599. if Player.Character.WeaponActivated.Value == nil then break end
  600. if pcall(function() if Player.Character.WeaponActivated.Value.Parent == nil then return true end end) then break end
  601. wait()
  602. end
  603. swordType = "normal"
  604. EnableLimb(1, Player.Character)
  605. removeParts("hand")
  606. makeParts("holster")
  607. end
  608.  
  609.  
  610. if script.Parent.ClassName ~= "HopperBin" then
  611. if Player == nil then print("Error: Player not found!") return end
  612. Tool = Instance.new("HopperBin")
  613. Tool.Name = Name
  614. Tool.Parent = Player.Backpack
  615. script.Name = "Main"
  616. script.Parent = Tool
  617. end wait() if script.Parent.ClassName == "HopperBin" then
  618. while script.Parent.Parent.ClassName ~= "Backpack" do
  619. wait()
  620. end
  621. Player = script.Parent.Parent.Parent
  622. makeParts("holster")
  623. script.Parent.Selected:connect(onSelected)
  624. script.Parent.Deselected:connect(onDeselected)
  625. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement