thngf

Untitled

Oct 2nd, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. --Made by Luckymaxer
  2.  
  3. Tool = script.Parent
  4. Handle = Tool:WaitForChild("Handle")
  5.  
  6. Players = game:GetService("Players")
  7.  
  8. Animations = {}
  9.  
  10. ServerControl = Tool:WaitForChild("ServerControl")
  11. ClientControl = Tool:WaitForChild("ClientControl")
  12.  
  13. Rate = (1 / 60)
  14.  
  15. ToolEquipped = false
  16.  
  17. function SetAnimation(mode, value)
  18. if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
  19. for i, v in pairs(Animations) do
  20. if v.Animation == value.Animation then
  21. v.AnimationTrack:Stop()
  22. table.remove(Animations, i)
  23. end
  24. end
  25. local AnimationTrack = Humanoid:LoadAnimation(value.Animation)
  26. table.insert(Animations, {Animation = value.Animation, AnimationTrack = AnimationTrack})
  27. AnimationTrack:Play(value.FadeTime, value.Weight, value.Speed)
  28. elseif mode == "StopAnimation" and value then
  29. for i, v in pairs(Animations) do
  30. if v.Animation == value.Animation then
  31. v.AnimationTrack:Stop(value.FadeTime)
  32. table.remove(Animations, i)
  33. end
  34. end
  35. end
  36. end
  37.  
  38. function CheckIfAlive()
  39. return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Player and Player.Parent) and true) or false)
  40. end
  41.  
  42. function Equipped(Mouse)
  43. Character = Tool.Parent
  44. Player = Players:GetPlayerFromCharacter(Character)
  45. Humanoid = Character:FindFirstChild("Humanoid")
  46. ToolEquipped = true
  47. if not CheckIfAlive() then
  48. return
  49. end
  50. Spawn(function()
  51. PlayerMouse = Mouse
  52. Mouse.Button1Down:connect(function()
  53. InvokeServer("Button1Click", {Down = true})
  54. end)
  55. Mouse.Button1Up:connect(function()
  56. InvokeServer("Button1Click", {Down = false})
  57. end)
  58. Mouse.KeyDown:connect(function(Key)
  59. InvokeServer("KeyPress", {Key = Key, Down = true})
  60. end)
  61. Mouse.KeyUp:connect(function(Key)
  62. InvokeServer("KeyPress", {Key = Key, Down = false})
  63. end)
  64. end)
  65. end
  66.  
  67. function Unequipped()
  68. for i, v in pairs(Animations) do
  69. if v and v.AnimationTrack then
  70. v.AnimationTrack:Stop()
  71. end
  72. end
  73. Animations = {}
  74. ToolEquipped = false
  75. end
  76.  
  77. function InvokeServer(mode, value)
  78. pcall(function()
  79. local ServerReturn = ServerControl:InvokeServer(mode, value)
  80. return ServerReturn
  81. end)
  82. end
  83.  
  84. function OnClientInvoke(mode, value)
  85. if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
  86. SetAnimation("PlayAnimation", value)
  87. elseif mode == "StopAnimation" and value then
  88. SetAnimation("StopAnimation", value)
  89. elseif mode == "PlaySound" and value then
  90. value:Play()
  91. elseif mode == "StopSound" and value then
  92. value:Stop()
  93. elseif mode == "MousePosition" then
  94. return ((PlayerMouse and {Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target, TargetSurface = PlayerMouse.TargetSurface}) or nil)
  95. end
  96. end
  97.  
  98. ClientControl.OnClientInvoke = OnClientInvoke
  99. Tool.Equipped:connect(Equipped)
  100. Tool.Unequipped:connect(Unequipped)
Advertisement
Add Comment
Please, Sign In to add comment