Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 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. Sounds = {{145180529, "Slash"}, {145180550, "Slash"}}
  12. SlashSounds = {}
  13.  
  14. local UnsheathSound = Instance.new("Sound")
  15. UnsheathSound.SoundId = "http://www.roblox.com/Asset/?id=145180523"
  16. UnsheathSound.Parent = sword
  17. UnsheathSound.Volume = .2
  18.  
  19. function attack()
  20. if not enabled then
  21. return
  22. end
  23. local humanoid = sword.Parent.Humanoid
  24. local currAnim = humanoid:LoadAnimation(anims[math.random(#anims)])-- pick a random animation
  25. enabled = false
  26. mouse.Icon="rbxasset://textures\\GunWaitCursor.png"
  27. currAnim:Play()
  28. wait(.75)
  29. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  30. enabled = true
  31. SlashSounds[math.random(#SlashSounds)]:Play()
  32. end
  33.  
  34. function spinsword(spintime)
  35. delay(0,function()
  36. local startspin=tick()
  37. local endspin=startspin+spintime
  38. while tick()<endspin do
  39. sp.Grip=currentgrip*CFrame.Angles(math.pi*2*((tick()-startspin)/spintime),0,0)
  40. wait()
  41. end
  42. sp.Grip = currentgrip
  43. end)
  44. end
  45.  
  46. sword.Equipped:Connect(function()
  47.  
  48. UnsheathSound:play()
  49. atConn = mouse.Button1Down:Connect(attack)
  50. end)
  51. sword.Unequipped:Connect(function()
  52. atConn:Disconnect()-- I forgot how2tool
  53. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement