ShadowClawPlays

Sword script

Jul 15th, 2022 (edited)
1,616
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- Variables
  2. local tool = script.Parent
  3. local Damage = 30
  4.  
  5. local SlashAnim = script:WaitForChild("Slash")
  6. local SlashAnimTrack
  7.  
  8. local SlashSound = script:WaitForChild("SlashSound")
  9. local HitSound = script:WaitForChild("HitSound")
  10.  
  11. local hitCharacters = {}
  12. local debounce = false
  13.  
  14. -- tool when used
  15.  
  16. tool.Activated:Connect(function()
  17.  
  18.     if debounce then return end
  19.  
  20.     debounce = true
  21.  
  22.     local humanoid = script.Parent.Parent.Humanoid
  23.     if not SlashAnimTrack then SlashAnimTrack = humanoid:LoadAnimation(SlashAnim) end
  24.  
  25.     SlashAnimTrack:Play()
  26.  
  27.     task.wait(0.1) 
  28.  
  29.     SlashSound:Play()
  30.  
  31.     task.wait(0.1)
  32.  
  33.     debounce = false
  34. end)
  35.  
  36. tool.Blade.Touched:Connect(function(touch)
  37.  
  38.     if hitCharacters[touch.Parent] or not debounce then return end
  39.  
  40.     if touch.Parent:FindFirstChild("Humanoid") then
  41.         touch.Parent.Humanoid:TakeDamage(Damage)
  42.         HitSound:Play()
  43.         hitCharacters[touch.Parent] = true
  44.         task.wait(0.1)
  45.         hitCharacters[touch.Parent] = nil
  46.     end
  47. end)
Comments
Add Comment
Please, Sign In to add comment