Advertisement
OofNoob

Chara's Real Knife tool script by Miniix15

Apr 11th, 2018
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.13 KB | None | 0 0
  1. -- Made by Miniix15
  2. --Converted with PenguinAnonymous's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. Animation1 = Instance.new("Animation")
  21. Animation2 = Instance.new("Animation")
  22. Animation3 = Instance.new("Animation")
  23. Animation4 = Instance.new("Animation")
  24. Animation5 = Instance.new("Animation")
  25. Part6 = Instance.new("Part")
  26. Sound7 = Instance.new("Sound")
  27. Sound8 = Instance.new("Sound")
  28. Sound9 = Instance.new("Sound")
  29. SpecialMesh10 = Instance.new("SpecialMesh")
  30. ParticleEmitter11 = Instance.new("ParticleEmitter")
  31. ParticleEmitter12 = Instance.new("ParticleEmitter")
  32. LocalScript13 = Instance.new("LocalScript")
  33. LocalScript14 = Instance.new("LocalScript")
  34. LocalScript15 = Instance.new("LocalScript")
  35. Script16 = Instance.new("Script")
  36. Script17 = Instance.new("Script")
  37. Script18 = Instance.new("Script")
  38. BoolValue19 = Instance.new("BoolValue")
  39. BoolValue20 = Instance.new("BoolValue")
  40. BoolValue21 = Instance.new("BoolValue")
  41. BoolValue22 = Instance.new("BoolValue")
  42. Tool0.Name = "Real Knife"
  43. Tool0.Parent = mas
  44. Tool0.GripPos = Vector3.new(0, -1, -0.100000001)
  45. Animation1.Name = "ThrowCharge"
  46. Animation1.Parent = Tool0
  47. Animation1.AnimationId = "http://www.roblox.com/Asset?ID=93103762"
  48. Animation2.Name = "Throw"
  49. Animation2.Parent = Tool0
  50. Animation2.AnimationId = "http://www.roblox.com/Asset?ID=89147993"
  51. Animation3.Name = "StabPunch"
  52. Animation3.Parent = Tool0
  53. Animation3.AnimationId = "http://www.roblox.com/Asset?ID=89134792"
  54. Animation4.Name = "KnifeIdle"
  55. Animation4.Parent = Tool0
  56. Animation5.Name = "DownStab"
  57. Animation5.Parent = Tool0
  58. Animation5.AnimationId = "http://www.roblox.com/Asset?ID=89133529"
  59. Part6.Name = "Handle"
  60. Part6.Parent = Tool0
  61. Part6.Material = Enum.Material.DiamondPlate
  62. Part6.BrickColor = BrickColor.new("Really black")
  63. Part6.Reflectance = 0.0099999997764826
  64. Part6.Rotation = Vector3.new(-180, 0, -180)
  65. Part6.Elasticity = 0
  66. Part6.FormFactor = Enum.FormFactor.Custom
  67. Part6.Size = Vector3.new(0.400000006, 3, 0.699999988)
  68. Part6.CFrame = CFrame.new(-6, 1.50003195, -12, -1, 0, 0, 0, 1, 0, 0, 0, -1)
  69. Part6.BottomSurface = Enum.SurfaceType.Smooth
  70. Part6.TopSurface = Enum.SurfaceType.Smooth
  71. Part6.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  72. Part6.Position = Vector3.new(-6, 1.50003195, -12)
  73. Part6.Orientation = Vector3.new(0, 180, 0)
  74. Part6.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  75. Sound7.Name = "Swoosh"
  76. Sound7.Parent = Part6
  77. Sound7.SoundId = "http://www.roblox.com/asset?id=153647529"
  78. Sound7.Volume = 1
  79. Sound7.PlayOnRemove = true
  80. Sound8.Name = "Swoosh1"
  81. Sound8.Parent = Part6
  82. Sound8.SoundId = "rbxassetid://1072555790"
  83. Sound8.Volume = 1
  84. Sound8.PlayOnRemove = true
  85. Sound9.Name = "Ting"
  86. Sound9.Parent = Part6
  87. Sound9.SoundId = "http://www.roblox.com/asset?id=153647529"
  88. Sound9.Volume = 0.20000000298023
  89. SpecialMesh10.Parent = Part6
  90. SpecialMesh10.MeshId = "http://www.roblox.com/asset/?id=121944778 "
  91. SpecialMesh10.TextureId = "rbxassetid://362719969"
  92. SpecialMesh10.MeshType = Enum.MeshType.FileMesh
  93. ParticleEmitter11.Name = "Light Particles"
  94. ParticleEmitter11.Parent = Part6
  95. ParticleEmitter11.Transparency = NumberSequence.new(0.69999998807907,0.69999998807907)
  96. ParticleEmitter11.Size = NumberSequence.new(0.20000000298023,0.20000000298023)
  97. ParticleEmitter11.LightEmission = 1
  98. ParticleEmitter11.Texture = "http://www.roblox.com/asset/?id=162595515"
  99. ParticleEmitter11.Lifetime = NumberRange.new(0.30000001192093, 0.30000001192093)
  100. ParticleEmitter11.Rate = 9999
  101. ParticleEmitter11.RotSpeed = NumberRange.new(99999, 99999)
  102. ParticleEmitter11.VelocitySpread = 99
  103. ParticleEmitter12.Name = "Hit Particles"
  104. ParticleEmitter12.Parent = Part6
  105. ParticleEmitter12.Transparency = NumberSequence.new(0.69999998807907,0.69999998807907)
  106. ParticleEmitter12.Size = NumberSequence.new(0.40000000596046,0.40000000596046)
  107. ParticleEmitter12.Color = ColorSequence.new(Color3.new(1, 0, 0.0352941),Color3.new(1, 0, 0.0352941))
  108. ParticleEmitter12.LightEmission = 0.5
  109. ParticleEmitter12.Texture = "http://www.roblox.com/asset/?id=141116476"
  110. ParticleEmitter12.Lifetime = NumberRange.new(0.20000000298023, 0.20000000298023)
  111. ParticleEmitter12.Rate = inf
  112. ParticleEmitter12.Speed = NumberRange.new(1, 1)
  113. ParticleEmitter12.Color = ColorSequence.new(Color3.new(1, 0, 0.0352941),Color3.new(1, 0, 0.0352941))
  114. LocalScript13.Name = "KnifeScript"
  115. LocalScript13.Parent = Tool0
  116. table.insert(cors,sandbox(LocalScript13,function()
  117. --------------------- TEMPLATE BLADE WEAPON ---------------------------
  118. -- Waits for the child of the specified parent
  119. local function WaitForChild(parent, childName)
  120. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  121. return parent[childName]
  122. end
  123.  
  124.  
  125. local SLASH_DAMAGE = 999
  126. local DOWNSTAB_DAMAGE = 999
  127. local THROWING_DAMAGE = 999
  128. local HOLD_TO_THROW_TIME = 0.30
  129.  
  130.  
  131. local Damage = 999
  132.  
  133. local MyHumanoid = nil
  134. local MyTorso = nil
  135. local MyCharacter = nil
  136. local MyPlayer = nil
  137.  
  138. local Tool = script.Parent
  139. local Handle = WaitForChild(Tool, 'Handle')
  140.  
  141. local BlowConnection
  142. local Button1DownConnection
  143. local Button1UpConnection
  144.  
  145. local PlayStabPunch
  146. local PlayDownStab
  147. local PlayThrow
  148. local PlayThrowCharge
  149.  
  150. local IconUrl = Tool.TextureId -- URL to the weapon knife icon asset
  151.  
  152. local DebrisService = game:GetService('Debris')
  153. local PlayersService = game:GetService('Players')
  154.  
  155. local SlashSound
  156.  
  157. local HitPlayers = {}
  158.  
  159. local LeftButtonDownTime = nil
  160.  
  161. local Attacking = false
  162.  
  163. function Blow(hit)
  164. if Attacking then
  165. BlowDamage(hit, Damage)
  166. end
  167. end
  168.  
  169. function BlowDamage(hit, damage)
  170. local humanoid = hit.Parent:FindFirstChild('Humanoid')
  171. local player = PlayersService:GetPlayerFromCharacter(hit.Parent)
  172. if humanoid ~= nil and MyHumanoid ~= nil and humanoid ~= MyHumanoid then
  173. if not MyPlayer.Neutral then
  174. -- Ignore teammates hit
  175. if player and player ~= MyPlayer and player.TeamColor == MyPlayer.TeamColor then
  176. return
  177. end
  178. end
  179. -- final check, make sure weapon is in-hand
  180. local rightArm = MyCharacter:FindFirstChild('Right Arm')
  181. if (rightArm ~= nil) then
  182. -- Check if the weld exists between the hand and the weapon
  183. local joint = rightArm:FindFirstChild('RightGrip')
  184. if (joint ~= nil and (joint.Part0 == Handle or joint.Part1 == Handle)) then
  185. -- Make sure you only hit them once per swing
  186. TagHumanoid(humanoid, MyPlayer)
  187. print("Sending " .. damage)
  188.  
  189. local checksound = humanoid.Parent:findFirstChild("Sound")
  190. if checksound == nil then
  191. local givesound = script.Parent.Sound:clone()
  192. givesound.Parent = humanoid.Parent
  193. givesound.Disabled = false
  194. else
  195. checksound:remove()
  196. local givesound = script.Parent.Sound:clone()
  197. givesound.Parent = humanoid.Parent
  198. givesound.Disabled = false
  199. end
  200. wait()
  201. humanoid:TakeDamage(humanoid.MaxHealth)
  202. if humanoid.Health == math.huge or humanoid.MaxHealth == math.huge then
  203. humanoid.Parent:BreakJoints()
  204. end
  205. end
  206. end
  207. end
  208. end
  209.  
  210. function TagHumanoid(humanoid, player)
  211. -- Add more tags here to customize what tags are available.
  212. while humanoid:FindFirstChild('creator') do
  213. humanoid:FindFirstChild('creator'):Destroy()
  214. end
  215.  
  216. local creatorTag = Instance.new('ObjectValue')
  217. creatorTag.Value = player
  218. creatorTag.Name = 'creator'
  219. creatorTag.Parent = humanoid
  220. DebrisService:AddItem(creatorTag, 1.5)
  221.  
  222. local weaponIconTag = Instance.new('StringValue')
  223. weaponIconTag.Value = IconUrl
  224. weaponIconTag.Name = 'icon'
  225. weaponIconTag.Parent = creatorTag
  226. DebrisService:AddItem(weaponIconTag, 1.5)
  227. end
  228.  
  229. function HardAttack()
  230. Damage = SLASH_DAMAGE
  231. HitSound:play()
  232. if PlayStabPunch then
  233. PlayStabPunch.Value = true
  234. wait(1.0)
  235. PlayStabPunch.Value = false
  236. end
  237. end
  238.  
  239. function NormalAttack()
  240. Damage = DOWNSTAB_DAMAGE
  241. KnifeDown()
  242. HitSound:play()
  243. if PlayDownStab then
  244. PlayDownStab.Value = true
  245. wait(1.0)
  246. PlayDownStab.Value = false
  247. end
  248. KnifeUp()
  249. end
  250.  
  251. function ThrowAttack()
  252. KnifeOut()
  253. if PlayThrow then
  254. PlayThrow.Value = true
  255. wait()
  256. if not Handle then return end
  257. local throwingHandle = Handle:Clone()
  258. DebrisService:AddItem(throwingHandle, 5)
  259. throwingHandle.Parent = game.Workspace
  260. if MyCharacter and MyHumanoid then
  261. throwingHandle.Velocity = (MyHumanoid.TargetPoint - throwingHandle.CFrame.p).unit * 100
  262. -- set the orientation to the direction it is being thrown in
  263. throwingHandle.CFrame = CFrame.new(throwingHandle.CFrame.p, throwingHandle.CFrame.p + throwingHandle.Velocity) * CFrame.Angles(0, 0, math.rad(-90))
  264. local floatingForce = Instance.new('BodyForce', throwingHandle)
  265. floatingForce.force = Vector3.new(0, 196.2 * throwingHandle:GetMass() * 0.98, 0)
  266. local spin = Instance.new('BodyAngularVelocity', throwingHandle)
  267. spin.angularvelocity = throwingHandle.CFrame:vectorToWorldSpace(Vector3.new(0, -400, 0))
  268. end
  269. Handle.Transparency = 1
  270. -- Wait so that the knife has left the thrower's general area
  271. wait()
  272. if throwingHandle then
  273. local Throwevent = script.Parent.ThrowHandleHitWeld:Clone()
  274. Throwevent.Parent = throwingHandle
  275. Throwevent.Disabled = false
  276. local touchedConn = throwingHandle.Touched:connect(function(hit) print("hit throw") BlowDamage(hit, THROWING_DAMAGE) end)
  277. end
  278. -- must check if it still exists since we waited
  279. if throwingHandle then
  280. throwingHandle.CanCollide = true
  281. end
  282. wait(0.6)
  283. if Handle and PlayThrow then
  284. Handle.Transparency = 0
  285. PlayThrow.Value = false
  286. end
  287. end
  288. KnifeUp()
  289. end
  290.  
  291. function KnifeUp()
  292. Tool.GripForward = Vector3.new(0,0,-1)
  293. Tool.GripRight = Vector3.new(1,0,0)
  294. Tool.GripUp = Vector3.new(0,1,0)
  295. end
  296.  
  297. function KnifeDown()
  298. Tool.GripForward = Vector3.new(0,0,-1)
  299. Tool.GripRight = Vector3.new(1,0,0)
  300. Tool.GripUp = Vector3.new(0,-1,0)
  301. end
  302.  
  303. function KnifeOut()
  304. Tool.GripForward = Vector3.new(0,0,-1)
  305. Tool.GripRight = Vector3.new(1,0,0)
  306. Tool.GripUp = Vector3.new(0,1,0)
  307. end
  308.  
  309. Tool.Enabled = true
  310.  
  311. function OnLeftButtonDown()
  312. LeftButtonDownTime = time()
  313. if PlayThrowCharge then
  314. PlayThrowCharge.Value = true
  315. end
  316. end
  317.  
  318. function OnLeftButtonUp()
  319. if not Tool.Enabled then return end
  320. -- Reset the list of hit players every time we start a new attack
  321. HitPlayers = {}
  322. if PlayThrowCharge then
  323. PlayThrowCharge.Value = false
  324. end
  325. if Tool.Enabled and MyHumanoid and MyHumanoid.Health > 0 then
  326. Tool.Enabled = false
  327. local currTime = time()
  328. if LeftButtonDownTime and currTime - LeftButtonDownTime > HOLD_TO_THROW_TIME and
  329. currTime - LeftButtonDownTime < 1.15 then
  330. ThrowAttack()
  331. else
  332. Attacking = true
  333. if math.random(1, 2) == 1 then
  334. HardAttack()
  335. else
  336. NormalAttack()
  337. end
  338. Attacking = false
  339. end
  340. Tool.Enabled = true
  341. end
  342. end
  343.  
  344. function OnEquipped(mouse)
  345. PlayStabPunch = WaitForChild(Tool, 'PlayStabPunch')
  346. PlayDownStab = WaitForChild(Tool, 'PlayDownStab')
  347. PlayThrow = WaitForChild(Tool, 'PlayThrow')
  348. PlayThrowCharge = WaitForChild(Tool, 'PlayThrowCharge')
  349. SlashSound = WaitForChild(Handle, 'Swoosh1')
  350. HitSound = WaitForChild(Handle, 'Ting')
  351. SlashSound:play()
  352. BlowConnection = Handle.Touched:connect(Blow)
  353. MyCharacter = Tool.Parent
  354. MyTorso = MyCharacter:FindFirstChild('Torso')
  355. MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
  356. MyPlayer = PlayersService.LocalPlayer
  357. if mouse then
  358. Button1DownConnection = mouse.Button1Down:connect(OnLeftButtonDown)
  359. Button1UpConnection = mouse.Button1Up:connect(OnLeftButtonUp)
  360. end
  361. KnifeUp()
  362. end
  363.  
  364. function OnUnequipped()
  365. -- Unequip logic here
  366. if BlowConnection then
  367. BlowConnection:disconnect()
  368. BlowConnection = nil
  369. end
  370. if Button1DownConnection then
  371. Button1DownConnection:disconnect()
  372. Button1DownConnection = nil
  373. end
  374. if Button1UpConnection then
  375. Button1UpConnection:disconnect()
  376. Button1UpConnection = nil
  377. end
  378. MyHumanoid = nil
  379. end
  380.  
  381.  
  382. Tool.Equipped:connect(OnEquipped)
  383. Tool.Unequipped:connect(OnUnequipped)
  384.  
  385. end))
  386. LocalScript14.Name = "BladeGui"
  387. LocalScript14.Parent = Tool0
  388. table.insert(cors,sandbox(LocalScript14,function()
  389. local Tool = script.Parent
  390.  
  391. function OnButton1Down(mouse)
  392. if Tool.Enabled then
  393. mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
  394. else
  395. mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
  396. end
  397. while not Tool.Enabled do
  398. Tool.Changed:wait()
  399. end
  400. if Tool.Enabled then
  401. mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
  402. end
  403. end
  404.  
  405. function OnEquipped(mouse)
  406. if mouse == nil then
  407. print("Mouse not found")
  408. return
  409. end
  410.  
  411. mouse.Icon = 'http://www.roblox.com/asset/?id=54019936'
  412. mouse.Button1Down:connect(function() OnButton1Down(mouse) end)
  413. end
  414.  
  415.  
  416. Tool.Equipped:connect(OnEquipped)
  417.  
  418. end))
  419. LocalScript15.Name = "AnimationScript"
  420. LocalScript15.Parent = Tool0
  421. table.insert(cors,sandbox(LocalScript15,function()
  422. -- Waits for the child of the specified parent
  423. local function WaitForChild(parent, childName)
  424. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  425. return parent[childName]
  426. end
  427.  
  428. local Tool = script.Parent
  429.  
  430. local downStabAnim
  431. local stabPunchAnim
  432. local throwAnim
  433. local throwChargeAnim
  434.  
  435. local MyHumanoid
  436.  
  437. -- This table will make sure that when we stop an animation it is
  438. -- because it is the only animation of it running
  439. local PlayCountTable = {}
  440.  
  441.  
  442. local function PlayAnimation(animation, valueToCheck, animationLength)
  443. if valueToCheck and valueToCheck.Value then
  444. if MyHumanoid then
  445. animation:Play()
  446. if PlayCountTable[animation] then
  447. PlayCountTable[animation] = PlayCountTable[animation] + 1
  448. end
  449. -- wait the duration of the animation
  450. if animationLength then
  451. wait(animationLength)
  452. if PlayCountTable[animation] then
  453. PlayCountTable[animation] = PlayCountTable[animation] - 1
  454. if PlayCountTable[animation] == 0 then
  455. animation:Stop()
  456. end
  457. end
  458. end
  459. end
  460. end
  461. end
  462.  
  463. function OnEquipped()
  464. MyHumanoid = Tool.Parent:FindFirstChild('Humanoid')
  465. downStabAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'DownStab'))
  466. PlayCountTable[downStabAnim] = 0
  467. stabPunchAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'StabPunch'))
  468. PlayCountTable[stabPunchAnim] = 0
  469. throwAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'Throw'))
  470. PlayCountTable[throwAnim] = 0
  471. throwChargeAnim = MyHumanoid:LoadAnimation(WaitForChild(Tool, 'ThrowCharge'))
  472. PlayCountTable[throwChargeAnim] = 0
  473.  
  474.  
  475. local playStabPunch = WaitForChild(Tool, 'PlayStabPunch')
  476. local playDownStab = WaitForChild(Tool, 'PlayDownStab')
  477. local playThrow = WaitForChild(Tool, 'PlayThrow')
  478. local playThrowCharge = WaitForChild(Tool, 'PlayThrowCharge')
  479.  
  480. playStabPunch.Changed:connect(function() PlayAnimation(stabPunchAnim, playStabPunch, 1.0) end)
  481. playDownStab.Changed:connect(function() PlayAnimation(downStabAnim, playDownStab, 1.0) end)
  482. playThrow.Changed:connect(function() PlayAnimation(throwAnim, playThrow, 1.5) end)
  483. playThrowCharge.Changed:connect(function(value)
  484. if value then
  485. PlayAnimation(throwChargeAnim, playThrowCharge, 1.0)
  486. else
  487. throwChargeAnim:Stop()
  488. end
  489. end)
  490. end
  491.  
  492. function OnUnequipped()
  493. if downStabAnim then
  494. downStabAnim:Stop()
  495. downStabAnim = nil
  496. end
  497. if stabPunchAnim then
  498. stabPunchAnim:Stop()
  499. stabPunchAnim = nil
  500. end
  501. if throwAnim then
  502. throwAnim:Stop()
  503. throwAnim = nil
  504. end
  505. if throwChargeAnim then
  506. throwChargeAnim:Stop()
  507. throwChargeAnim = nil
  508. end
  509. PlayCountTable = {}
  510. end
  511.  
  512. Tool.Equipped:connect(OnEquipped)
  513. Tool.Unequipped:connect(OnUnequipped)
  514.  
  515.  
  516. end))
  517. Script16.Name = "ThrowHandleHitWeld"
  518. Script16.Parent = Tool0
  519. Script16.Disabled = true
  520. table.insert(cors,sandbox(Script16,function()
  521. arrow = script.Parent
  522.  
  523.  
  524. local HitSound = Instance.new("Sound")
  525. HitSound.SoundId = "http://www.roblox.com/asset?id=437475935"
  526. HitSound.Parent = arrow
  527. HitSound.Volume = .5
  528.  
  529.  
  530. function stick(hit)
  531.  
  532. local AV = arrow:findFirstChild("BodyForce")
  533. local FO = arrow:findFirstChild("BodyAngularVelocity")
  534.  
  535. if AV ~= nil then AV:remove() end
  536. if FO ~= nil then FO:remove() end
  537.  
  538. -- joint myself to the thing i hit
  539.  
  540. local weld = Instance.new("Weld")
  541.  
  542. weld.Name = "PieWeld"
  543. weld.Part0 = arrow
  544. weld.Part1 = hit
  545.  
  546. local backupweld = Instance.new("Weld")
  547.  
  548. backupweld.Name = "PieWeldBackup"
  549. backupweld.Part0 = arrow
  550. backupweld.Part1 = hit
  551.  
  552. -- correction term to account for average skew between physics update and heartbeat
  553. local HitPos = arrow.Position --+ (-arrow.Velocity * (1/60)) --+ (arrow.CFrame.lookVector * .5)
  554.  
  555. local CJ = CFrame.new(HitPos)
  556. local C0 = arrow.CFrame:inverse() *CJ
  557. local C1 = hit.CFrame:inverse() * CJ
  558.  
  559. weld.C0 = C0
  560. weld.C1 = C1
  561.  
  562. weld.Parent = arrow
  563.  
  564. backupweld.C0 = C0
  565. backupweld.C1 = C1
  566.  
  567. backupweld.Parent = arrow
  568.  
  569. end
  570.  
  571.  
  572. function onTouched(hit)
  573.  
  574. connection:disconnect()
  575.  
  576. stick(hit)
  577. HitSound:Play()
  578.  
  579.  
  580. end
  581.  
  582.  
  583.  
  584. connection = arrow.Touched:connect(onTouched)
  585.  
  586.  
  587.  
  588. wait(2)
  589.  
  590. if (arrow:FindFirstChild("PieWeld") ~= nil) then
  591. arrow.PieWeld:Remove()
  592. end
  593.  
  594. wait(8)
  595.  
  596. arrow.Parent = nil
  597. end))
  598. Script17.Name = "SoundScript"
  599. Script17.Parent = Tool0
  600. table.insert(cors,sandbox(Script17,function()
  601. -- Waits for the child of the specified parent
  602. local function WaitForChild(parent, childName)
  603. while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
  604. return parent[childName]
  605. end
  606.  
  607.  
  608. local Tool = script.Parent
  609. local Handle = WaitForChild(Tool, 'Handle')
  610. local Debounce = false
  611.  
  612. local TouchConnection
  613.  
  614.  
  615. function OnTouched(hit)
  616. local humanoid = hit.Parent:findFirstChild('Humanoid')
  617. if Debounce == false then
  618. Debounce = true
  619. if humanoid then
  620.  
  621. else
  622. Handle.Ting:Play()
  623. end
  624. end
  625. wait(0.5)
  626. Debounce = false
  627. end
  628.  
  629.  
  630. Tool.Equipped:connect(function()
  631. TouchConnection = Handle.Touched:connect(OnTouched)
  632. end)
  633.  
  634. Tool.Unequipped:connect(function()
  635. if TouchConnection then
  636. TouchConnection:disconnect()
  637. TouchConnection = nil
  638. end
  639. end)
  640.  
  641. end))
  642. Script18.Name = "Sound"
  643. Script18.Parent = Tool0
  644. Script18.Disabled = true
  645. table.insert(cors,sandbox(Script18,function()
  646. -- For knife
  647.  
  648. function waitForChild(parent, childName)
  649. local child = parent:findFirstChild(childName)
  650. if child then return child end
  651. while true do
  652. child = parent.ChildAdded:wait()
  653. if child.Name==childName then return child end
  654. end
  655. end
  656.  
  657. function newSound(id)
  658. local sound = Instance.new("Sound")
  659. sound.SoundId = id
  660. sound.archivable = false
  661. sound.Parent = script.Parent.Head
  662. return sound
  663. end
  664.  
  665. -- declarations
  666.  
  667. local sDied = newSound("http://www.roblox.com/asset?id=1072559190")
  668. local sFallingDown = newSound("rbxasset://sounds/splat.wav")
  669. local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav")
  670. local sGettingUp = newSound("rbxasset://sounds/hit.wav")
  671. local sJumping = newSound("rbxasset://sounds/button.wav")
  672. local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3")
  673. sRunning.Looped = true
  674.  
  675. local Figure = script.Parent
  676. local Head = waitForChild(Figure, "Head")
  677. local Humanoid = waitForChild(Figure, "Humanoid")
  678.  
  679. -- functions
  680.  
  681. function onDied()
  682. sDied:Play()
  683. end
  684.  
  685. function onState(state, sound)
  686. if state then
  687. sound:Play()
  688. else
  689. sound:Pause()
  690. end
  691. end
  692.  
  693. function onRunning(speed)
  694. if speed>0.01 then
  695. sRunning:Play()
  696. else
  697. sRunning:Pause()
  698. end
  699. end
  700.  
  701. -- connect up
  702.  
  703. Humanoid.Died:connect(onDied)
  704. Humanoid.Running:connect(onRunning)
  705. Humanoid.Jumping:connect(function(state) onState(state, sJumping) end)
  706. Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end)
  707. Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end)
  708. Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end)
  709.  
  710. end))
  711. BoolValue19.Name = "PlayThrowCharge"
  712. BoolValue19.Parent = Tool0
  713. BoolValue20.Name = "PlayThrow"
  714. BoolValue20.Parent = Tool0
  715. BoolValue21.Name = "PlayStabPunch"
  716. BoolValue21.Parent = Tool0
  717. BoolValue22.Name = "PlayDownStab"
  718. BoolValue22.Parent = Tool0
  719. for i,v in pairs(mas:GetChildren()) do
  720. v.Parent = game:GetService("Players").LocalPlayer.Character
  721. pcall(function() v:MakeJoints() end)
  722. end
  723. mas:Destroy()
  724. for i,v in pairs(cors) do
  725. spawn(function()
  726. pcall(v)
  727. end)
  728. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement