Advertisement
InTesting

Gun Test (Update 1)

Dec 30th, 2018
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.43 KB | None | 0 0
  1. local obj_player = owner
  2.  
  3. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  4. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  5. do
  6.     print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  7.     script.Parent = Player.Character
  8.  
  9.     --RemoteEvent for communicating
  10.     local Event = Instance.new("RemoteEvent")
  11.     Event.Name = "UserInput_Event"
  12.     --Fake event to make stuff like Mouse.KeyDown work
  13.     local function fakeEvent()
  14.         local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  15.         t.connect = t.Connect
  16.         return t
  17.     end
  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.     Event.OnServerEvent:Connect(function(plr,io)
  37.         if plr~=Player then return end
  38.         if io.isMouse then
  39.             m.Target = io.Target
  40.             m.Hit = io.Hit
  41.         else
  42.             local b = io.UserInputState == Enum.UserInputState.Begin
  43.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  44.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  45.             end
  46.             for _,t in pairs(CAS.Actions) do
  47.                 for _,k in pairs(t.Keys) do
  48.                     if k==io.KeyCode then
  49.                         t.Function(t.Name,io.UserInputState,io)
  50.                     end
  51.                 end
  52.             end
  53.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  54.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  55.         end
  56.     end)
  57.     Event.Parent = NLS([==[
  58.     local Player = game:GetService("Players").LocalPlayer
  59.     local Event = script:WaitForChild("UserInput_Event")
  60.     local UIS = game:GetService("UserInputService")
  61.     local input = function(io,a)
  62.         if a then return end
  63.         --Since InputObject is a client-side instance, we create and pass table instead
  64.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  65.     end
  66.     UIS.InputBegan:Connect(input)
  67.     UIS.InputEnded:Connect(input)
  68.     local Mouse = Player:GetMouse()
  69.     local h,t
  70.     --Give the server mouse data 30 times every second, but only if the values changed
  71.     --If player is not moving their mouse, client won't fire events
  72.     while wait(1/30) do
  73.         if h~=Mouse.Hit or t~=Mouse.Target then
  74.             h,t=Mouse.Hit,Mouse.Target
  75.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  76.         end
  77.     end]==],Player.Character)
  78.     Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  79. end
  80. function weld(part1,part2)
  81.     local weld = Instance.new("WeldConstraint",part1)
  82.     weld.Part0 = part1
  83.     weld.Part1 = part2
  84. end
  85. local person = owner.Character
  86. local tool = Instance.new("Tool")
  87. local Handle = Instance.new("Part")
  88. Handle.Name = "Handle"
  89. tool.Name = "Gun"
  90. tool.Parent = owner.Character
  91. Handle.Size = Vector3.new(.25,1,.25)
  92. Handle.Parent = tool
  93. local delay1 = false
  94. local attachment = Instance.new("Attachment",Handle)
  95. attachment.Visible  = false
  96. attachment.Position = Vector3.new(0,.5,-.875)
  97. local part = Instance.new("Part",tool)
  98. part.CanCollide = false
  99. part.Position = attachment.WorldPosition
  100. part.Orientation = Handle.Orientation
  101. part.Size = Vector3.new(.25,.25,2)
  102. weld(part,Handle)
  103.  
  104. tool.Equipped:Connect(function()
  105.    
  106.     tool.Activated:Connect(function()
  107.         if delay1==false then
  108.            
  109.             if mouse.Target==nil or mouse.Target.Parent==nil then
  110.             else
  111.                 local taP = mouse.Target.Parent
  112.                 if game.PlaceId==843468296 then
  113.                     if mouse.Target.Parent:IsA("Accessory") then
  114.                         if mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Humanoid") then
  115.                             mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand = true
  116.                         end
  117.                     elseif mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid") then
  118.                         mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand = true
  119.                     end
  120.                 else
  121.                     if mouse.Target.Name=="Head" then
  122.                         game.Workspace[mouse.Target.Parent.Name]:FindFirstChild("Head"):Destroy()
  123.                     elseif mouse.Target:FindFirstChildWhichIsA("Weld") then
  124.                         if mouse.Target:FindFirstChild("FaceCenterAttachment") or mouse.Target:FindFirstChild("FaceFrontAttachment") or mouse.Target:FindFirstChild("HairAttachment") or mouse.Target:FindFirstChild("HatAttachment")  then
  125.                             game.Workspace[mouse.Target.Parent.Parent.Name]:FindFirstChild("Head"):Destroy()
  126.                         else
  127.                             game.Workspace[mouse.Target.Parent.Parent.Name]:FindFirstChildWhichIsA("Humanoid"):TakeDamage(math.random(15,20))
  128.                         end
  129.                     elseif mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid") or mouse.Target.Parent:FindFirstChild("Humanoid") then
  130.                         if mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid").Health>=99999999 then
  131.                             game.Workspace[mouse.Target.Parent.Parent.Name]:FindFirstChild("Head"):Destroy()
  132.                         else
  133.                             game.Workspace[mouse.Target.Parent.Name]:FindFirstChildWhichIsA("Humanoid"):TakeDamage(math.random(15,20)) 
  134.                         end
  135.                     else
  136.                     end
  137.                 end
  138.                 local bu = Instance.new("Part",game.Workspace)
  139.                 bu.CanCollide = true
  140.                 bu.Position = part.Position + Vector3.new(0,.35,0)
  141.                 bu.Shape = "Cylinder"
  142.                 bu.Orientation = Handle.Orientation
  143.                 bu.Material = Enum.Material.Neon
  144.                 bu.BrickColor = BrickColor.new("New Yeller")
  145.                 bu.Size = Vector3.new(.2,.2,.25)
  146.                 local BF = Instance.new("BodyForce",bu)
  147.                 BF.Force = Vector3.new(0,.95,0)
  148.                 delay1=true
  149.                 wait(.1)
  150.                 delay1=false
  151.                 local SL = Instance.new("SurfaceLight",part)
  152.                 SL.Color = Color3.fromRGB(255, 247, 0)
  153.                 SL.Range = 4
  154.                 SL.Brightness = 100
  155.                 wait(.05)
  156.                 BF:Destroy()
  157.                 wait(1)
  158.                 SL:Destroy()
  159.                 wait(.5)
  160.                 bu.CanCollide = false
  161.                
  162.                
  163.             end
  164.         end
  165.     end)
  166.     mouse.KeyDown:Connect(function(key)
  167.         if key=="q" then
  168.             if mouse.Target==nil then
  169.             elseif mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid") then
  170.                 if mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand==false then
  171.                     mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand = true
  172.                 else
  173.                     mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand = false
  174.                 end
  175.             elseif mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Humanoid") then
  176.                 if mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand==false then
  177.                     mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand = true
  178.                 else
  179.                     mouse.Target.Parent.Parent:FindFirstChildWhichIsA("Humanoid").PlatformStand = false
  180.                 end
  181.             end
  182.         elseif key=="e" then
  183.             if mouse.Target.Parent:FindFirstChild("RightArm") then
  184.                 mouse.Target.Parent:FindFirstChild("RightArm"):Destroy()
  185.             elseif mouse.Target.Parent:FindFirstChild("RightUpperArm") then
  186.                 mouse.Target.Parent:FindFirstChild("RightUpperArm"):Destroy()
  187.             elseif mouse.Target.Parent.Parent:FindFirstChild("RightUpperArm") and mouse.Target.Parent:IsA("Accessory") then
  188.                 mouse.Target.Parent.Parent:FindFirstChild("RightUpperArm"):Destroy()
  189.             elseif mouse.Target.Parent.Parent:FindFirstChild("RightArm")  and mouse.Target.Parent:IsA("Accessory") then
  190.                 mouse.Target.Parent.Parent:FindFirstChild("RightArm"):Destroy()
  191.             end
  192.         end
  193.     end)
  194. end)
  195. while true do
  196.     person.Humanoid.Health = "inf"
  197.     person.Humanoid.PlatformStand = false
  198.     person.Humanoid.WalkSpeed = 25
  199.     person.Humanoid.JumpPower = 75
  200.     person.Humanoid.MaxHealth = "inf"
  201.     wait(.5)
  202. end
  203. print("Left mouse button click to fire a bullet:")
  204. print(" -Anywhere but player = 0")
  205. print(" -Hits the player anywhere but head = Randomizes 15 to 20")
  206. print(" -Hits player's head = Insta-kill")
  207. print("===========================================================")
  208. print("Q to paralize and unparalize them (WIP)")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement