Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 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. end
  30.  
  31. function spinsword(spintime)
  32. delay(0,function()
  33. local startspin=tick()
  34. local endspin=startspin+spintime
  35. while tick()<endspin do
  36. sp.Grip=currentgrip*CFrame.Angles(math.pi*2*((tick()-startspin)/spintime),0,0)
  37. wait()
  38. end
  39. sp.Grip = currentgrip
  40. end)
  41. end
  42.  
  43. sword.Equipped:Connect(function()
  44.  
  45. UnsheathSound:play()
  46. atConn = mouse.Button1Down:Connect(attack)
  47. end)
  48. sword.Unequipped:Connect(function()
  49. atConn:Disconnect()-- I forgot how2tool
  50. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement