hecknes

Laser

Mar 17th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  3. do
  4. print("FE Compatibility code by Mokiros")
  5. script.Parent = Player.Character
  6.  
  7. --RemoteEvent for communicating
  8. local Event = Instance.new("RemoteEvent")
  9. Event.Name = "UserInput_Event"
  10.  
  11. --Fake event to make stuff like Mouse.KeyDown work
  12. local function fakeEvent()
  13. local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  14. t.connect = t.Connect
  15. return t
  16. end
  17.  
  18. --Creating fake input objects with fake variables
  19. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  20. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  21. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  22. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  23. end}
  24. --Merged 2 functions into one by checking amount of arguments
  25. CAS.UnbindAction = CAS.BindAction
  26.  
  27. --This function will trigger the events that have been :Connect()'ed
  28. local function te(self,ev,...)
  29. local t = m[ev]
  30. if t and t._fakeEvent and t.Function then
  31. t.Function(...)
  32. end
  33. end
  34. m.TrigEvent = te
  35. UIS.TrigEvent = te
  36.  
  37. Event.OnServerEvent:Connect(function(plr,io)
  38. if plr~=Player then return end
  39. if io.isMouse then
  40. m.Target = io.Target
  41. m.Hit = io.Hit
  42. else
  43. local b = io.UserInputState == Enum.UserInputState.Begin
  44. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  45. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  46. end
  47. for _,t in pairs(CAS.Actions) do
  48. for _,k in pairs(t.Keys) do
  49. if k==io.KeyCode then
  50. t.Function(t.Name,io.UserInputState,io)
  51. end
  52. end
  53. end
  54. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  55. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  56. end
  57. end)
  58. Event.Parent = NLS([==[
  59. local Player = game:GetService("Players").LocalPlayer
  60. local Event = script:WaitForChild("UserInput_Event")
  61.  
  62. local UIS = game:GetService("UserInputService")
  63. local input = function(io,a)
  64. if a then return end
  65. --Since InputObject is a client-side instance, we create and pass table instead
  66. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  67. end
  68. UIS.InputBegan:Connect(input)
  69. UIS.InputEnded:Connect(input)
  70.  
  71. local Mouse = Player:GetMouse()
  72. local h,t
  73. --Give the server mouse data 30 times every second, but only if the values changed
  74. --If player is not moving their mouse, client won't fire events
  75. while wait(1/30) do
  76. if h~=Mouse.Hit or t~=Mouse.Target then
  77. h,t=Mouse.Hit,Mouse.Target
  78. Event:FireServer({isMouse=true,Target=t,Hit=h})
  79. end
  80. end]==],Player.Character)
  81. Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  82. end
  83.  
  84. if script.Parent.className~="HopperBin" then
  85. ma=Instance.new("HopperBin")
  86. ma.Name="Laser "
  87. --ma.Parent=game.Lighting
  88. ma.Parent=owner.Backpack
  89. script.Parent=ma
  90. end
  91.  
  92. local Selected = false
  93. local Shoot = true
  94. function Click(Target)
  95. if(Target.Target.Parent:findFirstChild("Humanoid")~=nil)then
  96. Target.Target.Parent.Humanoid.Health = 0
  97. end
  98. local P = Instance.new("Part")
  99. P.Name = "Laser"
  100. local Place0 = script.Parent.Parent.Parent.Character["Left Arm"].CFrame
  101. P.formFactor = 0
  102. P.Size = Vector3.new(1,1,(Place0.p - Target.Hit.p).magnitude)
  103. P.CFrame = CFrame.new((Place0.p + Target.Hit.p)/2,Place0.p)
  104. P.Parent = game.Workspace
  105. P.Color = Color3.new(0,0,1)
  106. P.Transparency = 0.5
  107. P.Reflectance = 0.5
  108. P.Anchored = true
  109. P.CanCollide = false
  110. local E = Instance.new("Explosion")
  111. E.Position = Target.Hit.p
  112. E.Parent = game.Workspace
  113. for i = 1,10 do
  114. P.Transparency = 0.5+(i*0.05)
  115. P.Reflectance = i*0.05
  116. wait(0.1)
  117. end
  118. P:Rremove()
  119. end
  120. function Select(Mouse)
  121. local Arm = script.Parent.Parent.Parent.Character:findFirstChild("Left Arm")
  122. if(Arm==nil)then
  123. script.Parent:Remove()
  124. script:Remove()
  125. end
  126. Selected = true
  127. local Torso = script.Parent.Parent.Parent.Character:findFirstChild("Torso")
  128. if(Torso==nil)then
  129. script.Parent:Remove()
  130. script:Remove()
  131. end
  132. local ArmWeld = Torso:findFirstChild("Left Shoulder")
  133. if(ArmWeld~=nil)then
  134. ArmWeld.Parent = nil
  135. end
  136. Mouse.Button1Down:connect(function()Click(Mouse)end)
  137. Arm.Anchored = true
  138. while Selected do
  139. local Place0 = script.Parent.Parent.Parent.Character.Torso.CFrame
  140. Place0 = Place0 + ((Place0 * CFrame.fromEulerAnglesXYZ(math.pi/2,0,0)).lookVector * 0.5) + (Place0 * CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)).lookVector
  141. local Place1 = Place0 + ((Place0.p-Mouse.Hit.p).unit * -2)
  142. Arm.CFrame = CFrame.new((Place0.p + Place1.p)/2,Place0.p) * CFrame.fromEulerAnglesXYZ(-math.pi/2,0,0)
  143. wait()
  144. end
  145. Arm.Anchored = false
  146. if(ArmWeld~=nil)then
  147. ArmWeld.Parent = Torso
  148. end
  149. end
  150. function Deselect()
  151. Selected = false
  152. end
  153. script.Parent.Selected:connect(Select)
  154. script.Parent.Deselected:connect(Deselect)if script.Parent.className~="HopperBin" then
  155. ma=Instance.new("HopperBin")
  156. ma.Name="Laser "
  157. --ma.Parent=game.Lighting
  158. ma.Parent=owner.Backpack
  159. script.Parent=ma
  160. end
  161.  
  162. local Selected = false
  163. local Shoot = true
  164. function Click(Target)
  165. if(Target.Target.Parent:findFirstChild("Humanoid")~=nil)then
  166. Target.Target.Parent.Humanoid.Health = 0
  167. end
  168. local P = Instance.new("Part")
  169. P.Name = "Laser"
  170. local Place0 = script.Parent.Parent.Parent.Character["Left Arm"].CFrame
  171. P.formFactor = 0
  172. P.Size = Vector3.new(1,1,(Place0.p - Target.Hit.p).magnitude)
  173. P.CFrame = CFrame.new((Place0.p + Target.Hit.p)/2,Place0.p)
  174. P.Parent = game.Workspace
  175. P.Color = Color3.new(0,0,1)
  176. P.Transparency = 0.5
  177. P.Reflectance = 0.5
  178. P.Anchored = true
  179. P.CanCollide = false
  180. local E = Instance.new("Explosion")
  181. E.Position = Target.Hit.p
  182. E.Parent = game.Workspace
  183. for i = 1,10 do
  184. P.Transparency = 0.5+(i*0.05)
  185. P.Reflectance = i*0.05
  186. wait(0.1)
  187. end
  188. P:Rremove()
  189. end
  190. function Select(Mouse)
  191. local Arm = script.Parent.Parent.Parent.Character:findFirstChild("Left Arm")
  192. if(Arm==nil)then
  193. script.Parent:Remove()
  194. script:Remove()
  195. end
  196. Selected = true
  197. local Torso = script.Parent.Parent.Parent.Character:findFirstChild("Torso")
  198. if(Torso==nil)then
  199. script.Parent:Remove()
  200. script:Remove()
  201. end
  202. local ArmWeld = Torso:findFirstChild("Left Shoulder")
  203. if(ArmWeld~=nil)then
  204. ArmWeld.Parent = nil
  205. end
  206. Mouse.Button1Down:connect(function()Click(Mouse)end)
  207. Arm.Anchored = true
  208. while Selected do
  209. local Place0 = script.Parent.Parent.Parent.Character.Torso.CFrame
  210. Place0 = Place0 + ((Place0 * CFrame.fromEulerAnglesXYZ(math.pi/2,0,0)).lookVector * 0.5) + (Place0 * CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)).lookVector
  211. local Place1 = Place0 + ((Place0.p-Mouse.Hit.p).unit * -2)
  212. Arm.CFrame = CFrame.new((Place0.p + Place1.p)/2,Place0.p) * CFrame.fromEulerAnglesXYZ(-math.pi/2,0,0)
  213. wait()
  214. end
  215. Arm.Anchored = false
  216. if(ArmWeld~=nil)then
  217. ArmWeld.Parent = Torso
  218. end
  219. end
  220. function Deselect()
  221. Selected = false
  222. end
  223. script.Parent.Selected:connect(Select)
  224. script.Parent.Deselected:connect(Deselect)
Advertisement
Add Comment
Please, Sign In to add comment