Advertisement
daaa

Untitled

Jun 19th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 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. RunService = game:GetService("RunService")
  8. UserInputService = game:GetService("UserInputService")
  9.  
  10. Animations = {}
  11. LocalObjects = {}
  12.  
  13. ServerControl = Tool:WaitForChild("ServerControl")
  14. ClientControl = Tool:WaitForChild("ClientControl")
  15.  
  16. ToolEquipped = false
  17.  
  18. function SetAnimation(mode, value)
  19. if not ToolEquipped or not CheckIfAlive() then
  20. return
  21. end
  22. if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
  23. for i, v in pairs(Animations) do
  24. if v.Animation == value.Animation then
  25. v.AnimationTrack:Stop()
  26. table.remove(Animations, i)
  27. end
  28. end
  29. local AnimationTrack = Humanoid:LoadAnimation(value.Animation)
  30. table.insert(Animations, {Animation = value.Animation, AnimationTrack = AnimationTrack})
  31. AnimationTrack:Play(value.FadeTime, value.Weight, value.Speed)
  32. elseif mode == "StopAnimation" and value then
  33. for i, v in pairs(Animations) do
  34. if v.Animation == value.Animation then
  35. v.AnimationTrack:Stop(value.FadeTime)
  36. table.remove(Animations, i)
  37. end
  38. end
  39. end
  40. end
  41.  
  42. function DisableJump(Boolean)
  43. if PreventJump then
  44. PreventJump:disconnect()
  45. end
  46. if Boolean then
  47. PreventJump = Humanoid.Changed:connect(function(Property)
  48. if Property == "Jump" then
  49. Humanoid.Jump = false
  50. end
  51. end)
  52. end
  53. end
  54.  
  55. function CheckIfAlive()
  56. return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Head and Head.Parent and Player and Player.Parent) and true) or false)
  57. end
  58.  
  59. function Equipped(Mouse)
  60. Character = Tool.Parent
  61. Player = Players:GetPlayerFromCharacter(Character)
  62. Humanoid = Character:FindFirstChild("Humanoid")
  63. Head = Character:FindFirstChild("Head")
  64. ToolEquipped = true
  65. if not CheckIfAlive() then
  66. return
  67. end
  68. PlayerMouse = Player:GetMouse()
  69. Mouse.KeyDown:connect(function(Key)
  70. InvokeServer("KeyPress", {Key = Key, Down = true})
  71. end)
  72. Mouse.KeyUp:connect(function(Key)
  73. InvokeServer("KeyPress", {Key = Key, Down = false})
  74. end)
  75. end
  76.  
  77. function Unequipped()
  78. ToolEquipped = false
  79. for i, v in pairs(Animations) do
  80. if v and v.AnimationTrack then
  81. v.AnimationTrack:Stop()
  82. end
  83. end
  84. for i, v in pairs(LocalObjects) do
  85. if v.Object then
  86. v.Object.LocalTransparencyModifier = 0
  87. end
  88. end
  89. for i, v in pairs({PreventJump, ObjectLocalTransparencyModifier}) do
  90. if v then
  91. v:disconnect()
  92. end
  93. end
  94. Animations = {}
  95. LocalObjects = {}
  96. end
  97.  
  98. function InvokeServer(mode, value)
  99. local ServerReturn
  100. pcall(function()
  101. ServerReturn = ServerControl:InvokeServer(mode, value)
  102. end)
  103. return ServerReturn
  104. end
  105.  
  106. function OnClientInvoke(mode, value)
  107. if not ToolEquipped or not CheckIfAlive() or not mode then
  108. return
  109. end
  110. if mode == "PlayAnimation" and value then
  111. SetAnimation("PlayAnimation", value)
  112. elseif mode == "StopAnimation" and value then
  113. SetAnimation("StopAnimation", value)
  114. elseif mode == "PlaySound" and value then
  115. value:Play()
  116. elseif mode == "StopSound" and value then
  117. value:Stop()
  118. elseif mode == "MouseData" then
  119. return {Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target}
  120. elseif mode == "DisableJump" then
  121. DisableJump(value)
  122. elseif mode == "SetLocalTransparencyModifier" and value then
  123. pcall(function()
  124. local ObjectFound = false
  125. for i, v in pairs(LocalObjects) do
  126. if v == value then
  127. ObjectFound = true
  128. end
  129. end
  130. if not ObjectFound then
  131. table.insert(LocalObjects, value)
  132. if ObjectLocalTransparencyModifier then
  133. ObjectLocalTransparencyModifier:disconnect()
  134. end
  135. ObjectLocalTransparencyModifier = RunService.RenderStepped:connect(function()
  136. local Camera = game:GetService("Workspace").CurrentCamera
  137. for i, v in pairs(LocalObjects) do
  138. if v.Object and v.Object.Parent then
  139. local CurrentTransparency = v.Object.LocalTransparencyModifier
  140. local ViewDistance = (Camera.CoordinateFrame.p - Head.Position).Magnitude
  141. if ((not v.AutoUpdate and (CurrentTransparency == 1 or CurrentTransparency == 0)) or v.AutoUpdate) then
  142. if ((v.Distance and ViewDistance <= v.Distance) or not v.Distance) then
  143. v.Object.LocalTransparencyModifier = v.Transparency
  144. else
  145. v.Object.LocalTransparencyModifier = 0
  146. end
  147. end
  148. else
  149. table.remove(LocalObjects, i)
  150. end
  151. end
  152. end)
  153. end
  154. end)
  155. elseif mode == "SetCameraOffset" and value then
  156. pcall(function()
  157. Humanoid.CameraOffset = value
  158. end)
  159. end
  160. end
  161.  
  162. ClientControl.OnClientInvoke = OnClientInvoke
  163. Tool.Equipped:connect(Equipped)
  164. Tool.Unequipped:connect(Unequipped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement