Advertisement
HowToRoblox

ShurikenHandler

May 22nd, 2020
1,713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. local tool = script.Parent
  2.  
  3. local idle = script:WaitForChild("Idle")
  4. local idleTrack
  5.  
  6. local throw = script:WaitForChild("Throw")
  7. local throwTrack
  8.  
  9. local throwSound = script:WaitForChild("ThrowSound")
  10. local hitSound = script:WaitForChild("HitSound")
  11.  
  12. local debounce = false
  13. local charsHit = {}
  14.  
  15. local shuriken = game.ServerStorage.Shuriken
  16.  
  17.  
  18. tool.Equipped:Connect(function()
  19.    
  20.     if not idleTrack then idleTrack = tool.Parent.Humanoid:LoadAnimation(idle) end
  21.    
  22.     if not idleTrack.IsPlaying then idleTrack:Play() end   
  23. end)
  24.  
  25. tool.Unequipped:Connect(function()
  26.    
  27.     if idleTrack and idleTrack.IsPlaying then idleTrack:Stop() end
  28. end)
  29.  
  30.  
  31. tool.Activated:Connect(function()
  32.    
  33.     if debounce then return end
  34.     debounce = true
  35.    
  36.     if not throwTrack then throwTrack = tool.Parent.Humanoid:LoadAnimation(throw) end
  37.    
  38.     if not throwTrack.IsPlaying then throwTrack:Play() end
  39.    
  40.     if throwTrack.IsPlaying then throwTrack.Stopped:Wait() end
  41.    
  42.     throwSound:Play()
  43.    
  44.     tool.Handle.Transparency = 1
  45.    
  46.     local shurikenClone = shuriken:Clone()
  47.     shurikenClone.CFrame = tool.Handle.CFrame
  48.     shurikenClone.Parent = workspace
  49.    
  50.     local bf = Instance.new("BodyForce")
  51.     bf.Force = shurikenClone.CFrame.LookVector * 200 + Vector3.new(0, 120, 0)
  52.    
  53.     bf.Parent = shurikenClone
  54.    
  55.     local bav = Instance.new("BodyAngularVelocity")
  56.     bav.AngularVelocity = Vector3.new(0, -400, 0)
  57.    
  58.     bav.Parent = shurikenClone
  59.    
  60.    
  61.     game:GetService("Debris"):AddItem(shurikenClone, 20)
  62.    
  63.    
  64.     shurikenClone.Touched:Connect(function(touch)
  65.            
  66.         if touch.Parent:FindFirstChild("Humanoid") and touch.Parent ~= script.Parent.Parent and not charsHit[touch.Parent] then
  67.            
  68.             charsHit[touch.Parent] = true
  69.            
  70.             touch.Parent.Humanoid:TakeDamage(10)
  71.            
  72.             hitSound:Play()
  73.            
  74.             wait(0.4)
  75.            
  76.             charsHit[touch.Parent] = nil
  77.         end
  78.     end)
  79.    
  80.    
  81.     wait(0.4)
  82.    
  83.     debounce = false
  84.    
  85.     tool.Handle.Transparency = 0
  86.    
  87. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement