thngf

Untitled

Oct 2nd, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.11 KB | None | 0 0
  1. --Made by Luckymaxer
  2.  
  3. Tool = script.Parent
  4. Handle = Tool:WaitForChild("Handle")
  5. Smoke = Handle:WaitForChild("Smoke")
  6.  
  7. Players = game:GetService("Players")
  8. Debris = game:GetService("Debris")
  9.  
  10. RbxUtility = LoadLibrary("RbxUtility")
  11. Create = RbxUtility.Create
  12.  
  13. FadeScript = script:WaitForChild("FadeScript")
  14.  
  15. BaseUrl = "http://www.roblox.com/asset/?id="
  16.  
  17. BasePart = Create("Part"){
  18. Shape = Enum.PartType.Block,
  19. Material = Enum.Material.Plastic,
  20. TopSurface = Enum.SurfaceType.Smooth,
  21. BottomSurface = Enum.SurfaceType.Smooth,
  22. FormFactor = Enum.FormFactor.Custom,
  23. Size = Vector3.new(0.2, 0.2, 0.2),
  24. CanCollide = true,
  25. Locked = true,
  26. Anchored = false,
  27. }
  28.  
  29. Animations = {
  30. Spray = {Animation = Tool:WaitForChild("Spray"), FadeTime = nil, Weight = nil, Speed = nil},
  31. }
  32.  
  33. Sounds = {
  34. Audio = Handle:WaitForChild("Audio"),
  35. Spray = Handle:WaitForChild("Spray"),
  36. }
  37.  
  38. CoolDown = 2
  39. MaxRange = 10
  40. Images = {273067017}
  41.  
  42. AudioPlayed = false
  43. ToolEquipped = false
  44.  
  45. ServerControl = (Tool:FindFirstChild("ServerControl") or Create("RemoteFunction"){
  46. Name = "ServerControl",
  47. Parent = Tool,
  48. })
  49.  
  50. ClientControl = (Tool:FindFirstChild("ClientControl") or Create("RemoteFunction"){
  51. Name = "ClientControl",
  52. Parent = Tool,
  53. })
  54.  
  55. Handle.Transparency = 0
  56. Tool.Enabled = true
  57.  
  58. for i, v in pairs(Tool:GetChildren()) do
  59. if v:IsA("BasePart") and v ~= Handle then
  60. v:Destroy()
  61. end
  62. end
  63.  
  64. function CheckTableForString(Table, String)
  65. for i, v in pairs(Table) do
  66. if string.find(string.lower(String), string.lower(v)) then
  67. return true
  68. end
  69. end
  70. return false
  71. end
  72.  
  73. function CheckIntangible(Hit)
  74. local ProjectileNames = {"Water", "Arrow", "Projectile", "Effect", "Rail", "Laser", "Bullet"}
  75. if Hit and Hit.Parent then
  76. if CheckTableForString(ProjectileNames, Hit.Name) or Hit.Parent:FindFirstChild("Humanoid") then
  77. return true
  78. end
  79. end
  80. return false
  81. end
  82.  
  83. function CastRay(StartPos, Vec, Length, Ignore, DelayIfHit)
  84. local Ignore = ((type(Ignore) == "table" and Ignore) or {Ignore})
  85. local RayHit, RayPos, RayNormal = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(StartPos, Vec * Length), Ignore)
  86. if RayHit and CheckIntangible(RayHit) then
  87. if DelayIfHit then
  88. wait()
  89. end
  90. RayHit, RayPos, RayNormal = CastRay((RayPos + (Vec * 0.01)), Vec, (Length - ((StartPos - RayPos).magnitude)), Ignore, DelayIfHit)
  91. end
  92. return RayHit, RayPos, RayNormal
  93. end
  94.  
  95. function Activated()
  96. if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
  97. return
  98. end
  99. Tool.Enabled = false
  100. local MousePosition = InvokeClient("MousePosition")
  101. if not MousePosition then
  102. Tool.Enabled = true
  103. return
  104. end
  105. local MousePosition = MousePosition.Position
  106. if SmokePart and SmokePart.Parent then
  107. SmokePart:Destroy()
  108. end
  109. SmokePart = BasePart:Clone()
  110. SmokePart.Name = "SmokePart"
  111. SmokePart.Transparency = 1
  112. SmokePart.CanCollide = 1
  113. local SmokeParticles = Smoke:Clone()
  114. SmokeParticles.Enabled = true
  115. SmokeParticles.Parent = SmokePart
  116. local SmokeWeld = Create("Weld"){
  117. Part0 = Handle,
  118. Part1 = SmokePart,
  119. C0 = (CFrame.new(0, (Handle.Size.Y / 2), 0) * CFrame.Angles((-(math.pi * 2) / 3), 0, 0)),
  120. C1 = CFrame.new(0, 0, 0),
  121. Parent = SmokePart,
  122. }
  123. Debris:AddItem(SmokePart, (CoolDown + 1.5))
  124. SmokePart.Parent = Tool
  125. Delay(CoolDown, (function()
  126. SmokeParticles.Enabled = false
  127. end))
  128. Spawn(function()
  129. InvokeClient("PlayAnimation", Animations.Spray)
  130. end)
  131. if AudioPlayed then
  132. Sounds.Spray:Play()
  133. else
  134. Sounds.Audio:Play()
  135. end
  136. AudioPlayed = true
  137. local Direction = CFrame.new(SmokePart.Position, MousePosition)
  138. local RayHit, RayPos, RayNormal = CastRay(SmokePart.Position, Direction.lookVector, MaxRange, {Character}, false)
  139. if RayHit then
  140. local ImagePart = BasePart:Clone()
  141. ImagePart.Name = "Effect"
  142. ImagePart.Transparency = 1
  143. ImagePart.Size = Vector3.new(8, 4.5, 0.2)
  144. ImagePart.Anchored = false
  145. ImagePart.CanCollide = false
  146. local Decal = Create("Decal"){
  147. Name = "Decal",
  148. Texture = (BaseUrl .. Images[math.random(1, #Images)]),
  149. Transparency = 1,
  150. Face = Enum.NormalId.Front,
  151. Parent = ImagePart,
  152. }
  153. local FadeScriptClone = FadeScript:Clone()
  154. FadeScriptClone.Disabled = false
  155. FadeScriptClone.Parent = ImagePart
  156. local PartCFrame = CFrame.new(RayPos, (CFrame.new(RayPos) + RayNormal * 2).p)
  157. PartCFrame = (PartCFrame * CFrame.new(0, (ImagePart.Size.Y / 4), 0))
  158. --[[local NewDirection = CFrame.new(SmokePart.Position, RayPos)
  159. local OPX, OPY, OPZ, OXX, OYX, OZX, OXY, OYY, OZY, OXZ,OYZ, OZZ = PartCFrame:components()
  160. local NPX, NPY, NPZ, NXX, NYX, NZX, NXY, NYY, NZY, NXZ, NYZ, NZZ = NewDirection:components()
  161. PartCFrame = CFrame.new(
  162. OPX, OPY, OPZ,
  163. NXX, OYX, OZX,
  164. OXY, OYY, OZY,
  165. NXZ, OYZ, OZZ
  166. ) * CFrame.Angles(math.pi, 0, 0)]]
  167. local Weld = Create("Motor6D"){
  168. Name = "Stick",
  169. Part0 = ImagePart,
  170. Part1 = RayHit,
  171. C0 = PartCFrame:inverse(),
  172. C1 = RayHit.CFrame:inverse(),
  173. Parent = ImagePart,
  174. }
  175. Debris:AddItem(ImagePart, 10)
  176. ImagePart.Parent = game:GetService("Workspace")
  177. end
  178. wait(CoolDown)
  179. Sounds.Spray:Stop()
  180. Tool.Enabled = true
  181. end
  182.  
  183. function CheckIfAlive()
  184. return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0) and true) or false)
  185. end
  186.  
  187. function Equipped()
  188. Character = Tool.Parent
  189. Player = Players:GetPlayerFromCharacter(Character)
  190. Humanoid = Character:FindFirstChild("Humanoid")
  191. if not CheckIfAlive() then
  192. return
  193. end
  194. AudioPlayed = false
  195. ToolEquipped = true
  196. end
  197.  
  198. function Unequipped()
  199. if SmokePart and SmokePart.Parent then
  200. SmokePart:Destroy()
  201. end
  202. ToolEquipped = false
  203. end
  204.  
  205. function InvokeClient(Mode, Value)
  206. local ClientReturn = nil
  207. pcall(function()
  208. ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
  209. end)
  210. return ClientReturn
  211. end
  212.  
  213. function OnServerInvoke(player, Mode, Value)
  214. if player ~= Player or not ToolEquipped or not CheckIfAlive() or not Mode or not Value then
  215. return
  216. end
  217. end
  218.  
  219. ServerControl.OnServerInvoke = OnServerInvoke
  220.  
  221. Tool.Activated:connect(Activated)
  222. Tool.Equipped:connect(Equipped)
  223. Tool.Unequipped:connect(Unequipped)
Add Comment
Please, Sign In to add comment