Guest User

Untitled

a guest
Apr 26th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. -- This script picks a random animation and plays it when you attack.
  2.  
  3. math.randomseed(os.time());math.random();math.random();math.random();-- math.random() fix
  4.  
  5. local sword = script.Parent
  6. local handle = sword:WaitForChild("Handle")
  7. local anims = sword:WaitForChild("Animations"):GetChildren()
  8. local mouse = game.Players.LocalPlayer:GetMouse()
  9. local enabled = true
  10.  
  11.  
  12. local UnsheathSound = Instance.new("Sound")
  13. UnsheathSound.SoundId = "http://www.roblox.com/Asset/?id=145180523"
  14. UnsheathSound.Parent = sword
  15. UnsheathSound.Volume = .2
  16.  
  17. function attack()
  18. if not enabled then
  19. return
  20. end
  21. local humanoid = sword.Parent.Humanoid
  22. local currAnim = humanoid:LoadAnimation(anims[math.random(#anims)])-- pick a random animation
  23. enabled = false
  24. mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
  25. currAnim:Play()
  26. wait(.75)
  27. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  28. enabled = true
  29.  
  30. spinsword(spintime)
  31. delay(0,function()
  32. local startspin=tick()
  33. local endspin=startspin+spintime
  34. while tick()<endspin do
  35. sp.Grip=currentgrip*CFrame.Angles(math.pi*2*((tick()-startspin)/spintime),0,0)
  36. wait()
  37. end
  38. sp.Grip = currentgrip
  39. end)
  40. end
  41.  
  42.  
  43.  
  44. sword.Equipped:Connect(function()
  45.  
  46. UnsheathSound:play()
  47. atConn = mouse.Button1Down:Connect(attack)
  48. end)
  49. sword.Unequipped:Connect(function()
  50. atConn:Disconnect()-- I forgot how2tool
  51. end)
Advertisement
Add Comment
Please, Sign In to add comment