Advertisement
hunterwhitney85

Chainsaw Script

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