Advertisement
brianspy

Untitled

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