Advertisement
InTesting

E Bullet

Aug 13th, 2019
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.42 KB | None | 0 0
  1. print'https://pastebin.com/raw/C1Qn8AeX'
  2. local person = owner.Character
  3. local deb = game:GetService("Debris")
  4. local head = person:WaitForChild'Head'
  5. local _ = person:WaitForChild'HumanoidRootPart'
  6. local _ = person:WaitForChild'Humanoid'
  7.  
  8. -- // Weapons Closet \\ --
  9.  
  10. local function Damage(part)
  11.     --[[
  12.         // Description \\
  13.         This Function can damage a model with a given part. The default damage is 10,
  14.         and can not be adjusted If its replacing an unnamed Function in an event.
  15.         So it's best advised to change the
  16.         local varables within the Function. If a humanoid is not found, the model will
  17.         be killed.
  18.        
  19.         Local varables:
  20.             (Number) Kill_At_LargeHealth
  21.                 Automatically kills player if the humanoid's health is atleast of
  22.                 this number. If the number is 0, Then it does nothing.
  23.             (Number) Damage_humanoid
  24.                 Amount of damage towards the humanoid.
  25.     --]]
  26.     local Kill_At_LargeHealth = 100
  27.     local Damage_humanoid = 10
  28.     pcall(function()
  29.         local mod = part:FindFirstAncestorWhichIsA'Model'
  30.         if mod then
  31.             if mod~=workspace then
  32.                 local hum = mod:FindFirstChildWhichIsA'Humanoid'
  33.                 local target = mod:FindFirstChild'Head'or mod:FindFirstChild'Torso'or mod:FindFirstChild'UpperTorso'or mod:FindFirstChild'HumanoidRootPart'
  34.                 if hum then
  35.                     if hum.Health>Kill_At_LargeHealth and Kill_At_LargeHealth~=0 then
  36.                         hum.Health = 0
  37.                     else
  38.                         if hum.Health>0 then
  39.                             hum:TakeDamage(Damage_humanoid)
  40.                         end
  41.                     end
  42.                 elseif target then
  43.                     target:Destroy()
  44.                 else
  45.                     mod:BreakJoints()
  46.                 end
  47.             end
  48.         end
  49.     end)
  50. end
  51. local function CustomDamage(part,damage,Kill_At_Large_Health,noharm)
  52.     --[[
  53.         // Description \\
  54.         Similar to Damage() except you can not use it to replace an unamed Function
  55.         in an event, but this version has parameters.
  56.        
  57.         --> Manatory
  58.             (Instance) Part the Function will be checking.
  59.             (Number) Amount of damage.
  60.         --> Optional
  61.             (Number) Amount of health that a player needs in order to be automatically
  62.             killed.
  63.                 Default =
  64.                     0
  65.             (Instance) The Instance that the Function will be ignoring.
  66.                 Default =
  67.                     nil
  68.     --]]
  69.     if not Kill_At_Large_Health then
  70.         Kill_At_Large_Health = 0
  71.     end
  72.     pcall(function()
  73.         local mod = part:FindFirstAncestorWhichIsA'Model'
  74.         if mod then
  75.             if mod~=workspace then
  76.                 local bool = true
  77.                 if noharm then
  78.                     if noharm==mod then
  79.                         bool = false
  80.                     end
  81.                 end
  82.                 if bool then
  83.                     local hum = mod:FindFirstChildWhichIsA'Humanoid'
  84.                     local target = mod:FindFirstChild'Head'or mod:FindFirstChild'Torso'or mod:FindFirstChild'UpperTorso'or mod:FindFirstChild'HumanoidRootPart'
  85.                     if hum then
  86.                         if hum.Health>100 then
  87.                             hum.Health = 0
  88.                         else
  89.                             if hum.Health>0 then
  90.                                 hum:TakeDamage(damage)
  91.                             end
  92.                         end
  93.                     elseif target then
  94.                         target:Destroy()
  95.                     else
  96.                         mod:BreakJoints()
  97.                     end
  98.                 end
  99.             end
  100.         end
  101.     end)
  102. end
  103.  
  104. local function Laser_Beam(Start_Pos,End_Cframe,part_properties,beam_width,damage,
  105. delay_damage,noharm,duration)
  106.     --[[
  107.         // Description \\
  108.         Returns part that will mimic a laser beam. Often Varies from the style.
  109.         Best to keep the laser beam as a block and not a cylinder.
  110.        
  111.         Note theres alot of parameters so bare with me.
  112.        
  113.         M = Manatory
  114.         O = Optional
  115.        
  116.         M Start_Pos (Vector3) Position where the laser is starting.
  117.         M End_Cframe (CFrame) Needed to find the size of laser's length and the
  118.             End point.
  119.         O part_properties (Table) Properties of the laser. Use the format:
  120.                
  121.                 Property = value
  122.                
  123.             Default =
  124.                 (A typical brick except:)
  125.                
  126.                     Anchored = true,
  127.                     Parent = nil
  128.                
  129.         O beam_width (Number) The width and height of the laser.
  130.             Default =
  131.                 .1
  132.         O damage (Number) The amount of damage it will deal.
  133.             Default =
  134.                 10
  135.         O delay_damage (Number) Delay in seconds for the laser to rest.
  136.             Default =
  137.                 .1
  138.         O noharm (Instance) Instance for the noharm argument in CustomDamage(). Basically
  139.             ignores the model if the part it hits is a descendant of it.
  140.             Default =
  141.                 nil
  142.         O duration (Number) Amount in seconds before it disappears.
  143.             Default =
  144.                 1
  145.     --]]
  146.  
  147.     local part = Instance.new("Part")
  148.    
  149.     local function Check_Parameter(parameter,default)
  150.         if parameter then
  151.             if typeof(parameter)==typeof(default)then
  152.                 return parameter
  153.             else
  154.                 return default
  155.             end
  156.         else
  157.             return default
  158.         end
  159.     end
  160.     beam_width = Check_Parameter(beam_width,.1)
  161.     damage = Check_Parameter(damage,10)
  162.     delay_damage = Check_Parameter(delay_damage,.1)
  163.     duration = Check_Parameter(duration,1)
  164.    
  165.     local diff = (Start_Pos - End_Cframe.Position).Magnitude
  166.     for i,v in pairs(part_properties)do
  167.         pcall(function()
  168.             part[i] = v
  169.         end)
  170.     end
  171.     part.Anchored = true
  172.     part.CFrame = CFrame.new(Start_Pos,End_Cframe.Position) * CFrame.new(0,0,-diff/2)
  173.     part.Size = Vector3.new(beam_width,beam_width,diff)
  174.     local bool = true
  175.     part.Touched:Connect(function(h)
  176.         if bool then
  177.             bool = false
  178.             CustomDamage(h,damage,nil,noharm)
  179.             wait(delay_damage)
  180.             bool = true
  181.         end
  182.     end)
  183.    
  184.    
  185.     if duration then
  186.         local debris = game:GetService("Debris")
  187.         debris:AddItem(part,duration)
  188.     end
  189.    
  190.     return part
  191. end
  192. local function Bullet_Beam(Start_Pos,End_Cframe,part_properties,beam_width,damage,
  193.     delay_damage,bullet_length,type_of_travel,noharm,is_spawned,for_loop_steps,
  194.     for_loop_stud_step_forward,for_loop_stud_step_delay,tw_info)
  195.  
  196.     --[[
  197.         // Description \\
  198.         Fuck these parameters. I'm gonna make a simpler version some day.
  199.        
  200.         Returns a bullet. Note this can auto launch if you want to.
  201.        
  202.         M = Manatory
  203.         O = Optional
  204.    
  205.         M Start_Pos (Vector3) Position where the bullet starts.
  206.         M End_Cframe (CFrame) Necessary for the End Point of the bullet and the
  207.             direction.
  208.         O part_properties (Table) Table of properties for the bullet.
  209.             Default =
  210.                 Most of the properties of a typical part.
  211.         O beam_width (Number) The width and height of the bullet.
  212.             Default =
  213.                 .1
  214.         O damage (Number) The Damage it will deal.
  215.             Default =
  216.                 10
  217.         O delay_damage (Number) The delay of the bullet's damage
  218.             Default =
  219.                 1
  220.         O bullet_length (Number) The length of the bullet.
  221.             Default =
  222.                 .25
  223.         O type_of_travel (String) The Mode of travel:
  224.              - 'for_loop'; This mode will look laggy and will use a for loop.
  225.              - 'tween'; This mode will look smoother if in small servers and uses
  226.                 Tweenservice.
  227.              - (Default) nil
  228.             Note this will affect other parameters.
  229.         O noharm (Instance) Parameter for CustomDamage()
  230.             Default =
  231.                 nil
  232.         O (type_of_travel~=nil) is_spawned (Boolean) Makes a new thread for the
  233.             travel Function, If [type_of_travel] is not nil. In skid
  234.             language, it will prevent the script from yielding/pause the script.
  235.             Default =
  236.                 nil/false
  237.         O (type_of_travel~=nil) for_loop_steps (Number)
  238.             in type_of_travel=='for_loop', this number will be of how many times the
  239.                 bullet will phase through [for_loop_stud_step_forward] of studs.
  240.            
  241.             in type_of_travel=='tween', this number will be multiplied with
  242.                 [for_loop_stud_step_forward] to create the End point of the bullet.
  243.                
  244.             Default =
  245.                 10
  246.            
  247.         O (type_of_travel~=nil) for_loop_stud_step_forward (Number)
  248.             in type_of_travel=='for_loop', this number will be the amount of studs that
  249.                 it will go through per phase.
  250.                
  251.             in type_of_travel=='tween', this number will be multiplied with
  252.                 [for_loop_steps] to create the End point of the bullet.
  253.            
  254.             Default =
  255.                 1
  256.         O (type_of_travel=='for_loop') for_loop_stud_step_delay (Number)
  257.             This number will be the amout in seconds the bullet will pause before it
  258.             goes through another phase.
  259.            
  260.             Note this does not apply to (type_of_travel=='tween') because tween is
  261.             based so that the bullet will travel to its End Position.
  262.             (type_of_travel=='for_loop') is based so that it phases after a certiain
  263.             amount of numbers.
  264.            
  265.             Default =
  266.                 .1
  267.         O (type_of_travel=='tween') tw_info (TweenInfo)
  268.             This will determine the time, and Enum.EasingStyle it will use.
  269.             Default =
  270.                 TweenInfo.new(1,Enum.EasingStyle.Linear,
  271.                     Enum.EasingDirection.InOut,0,false,0)
  272.     --]]
  273.  
  274.     local part = Instance.new("Part")
  275.     local travel
  276.     local diff = (Start_Pos - End_Cframe.Position).Magnitude
  277.    
  278.     local function Check_Parameter(parameter,default)
  279.         if parameter then
  280.             if typeof(parameter)==typeof(default)then
  281.                 return parameter
  282.             else
  283.                 return default
  284.             end
  285.         else
  286.             return default
  287.         end
  288.     end
  289.     beam_width = Check_Parameter(beam_width,.1)
  290.     damage = Check_Parameter(damage,10)
  291.     delay_damage = Check_Parameter(delay_damage,.1)
  292.     bullet_length = Check_Parameter(bullet_length,.25)
  293.     for_loop_steps = Check_Parameter(for_loop_steps,10)
  294.     for_loop_stud_step_forward = Check_Parameter(for_loop_stud_step_forward,1)
  295.     for_loop_stud_step_delay = Check_Parameter(for_loop_stud_step_delay,.1)
  296.     tw_info = Check_Parameter(tw_info,TweenInfo.new(1,Enum.EasingStyle.Linear,
  297.                     Enum.EasingDirection.InOut,0,false,0))
  298.    
  299.     for i,v in pairs(part_properties)do
  300.         pcall(function()
  301.             part[i] = v
  302.         end)
  303.     end
  304.     part.Anchored = true
  305.     part.CFrame = CFrame.new(Start_Pos,End_Cframe.Position)
  306.     part.Size = Vector3.new(beam_width,beam_width,bullet_length)
  307.     local bool = true
  308.     part.Touched:Connect(function(h)
  309.         if bool then
  310.             bool = false
  311.             CustomDamage(h,damage,nil,noharm)
  312.             wait(delay_damage)
  313.             bool = true
  314.         end
  315.     end)
  316.    
  317.     if type_of_travel=='for_loop'then
  318.         travel = function()
  319.             for i=1,for_loop_steps do
  320.                 part.CFrame = part.CFrame *
  321.                     CFrame.new(0,0,-for_loop_stud_step_forward)
  322.                 wait(for_loop_stud_step_delay)
  323.             end
  324.             part.Anchored = false
  325.             part.CanCollide = false
  326.         end
  327.     elseif type_of_travel=='tween'then
  328.         travel = function()
  329.             local tws = game:GetService("TweenService")
  330.             local prop = {
  331.                 CFrame = part.CFrame * CFrame.new(0,0,-(for_loop_steps * for_loop_stud_step_forward))
  332.                 }
  333.             local an = tws:Create(part,tw_info,prop)
  334.             an:Play()
  335.             wait(an.TweenInfo.Time)
  336.             part.Anchored = false
  337.             part.CanCollide = false
  338.         end
  339.     end
  340.     if travel then
  341.         if is_spawned then
  342.             spawn(travel)
  343.         else
  344.             travel()
  345.         end
  346.     end
  347.    
  348.     return part
  349. end
  350.  
  351.  
  352.  
  353. local function On_OnServerEvent(player,...)
  354.     local parameters = {...}
  355.     if parameters[1]=='KeyDown'then
  356.         if parameters[2]=='e'then
  357.             local fold = person:FindFirstChild'Bullets'
  358.             if not fold then
  359.                 fold = Instance.new('Folder')
  360.                 fold.Name = 'Bullets'
  361.                 fold.Parent = person
  362.             end
  363.  
  364.             Bullet_Beam(head.Position + Vector3.new(0,5,0),parameters[3],
  365.                 {
  366.                     Parent = workspace
  367.                 }
  368.                 ,.1,10,.1,.25,
  369.                 'tween',person,true,100,1)
  370.         end
  371.     end
  372. end
  373.  
  374.  
  375. local function Get_Components_Of_Mouse(player)
  376.     --[[
  377.         Just skip to the bottom. Also note: No UserInputService
  378.     --]]
  379.    
  380.     local pchar = player.Character
  381.    
  382.     if pchar then
  383.         local Remote = pchar:FindFirstChild('∞RE_Mouse')
  384.         if not Remote then
  385.             Remote = Instance.new("RemoteEvent",pchar)
  386.             Remote.Name = 'RE_Mouse'
  387.         end
  388.        
  389.        
  390.        
  391.         Remote.Parent = NLS(
  392.             [[
  393. local lp = game:GetService'Players'.LocalPlayer
  394. local mouse = lp:GetMouse()
  395. local runs = game:GetService'RunService'
  396.  
  397. wait(1)
  398.  
  399. local re = script:WaitForChild('RE_Mouse')
  400. if re then
  401.     mouse.KeyDown:Connect(function(k)
  402.         re:FireServer('KeyDown',k,mouse.Hit)
  403.     end)
  404.     mouse.KeyUp:Connect(function(k)
  405.         re:FireServer('KeyUp',k)
  406.     end)
  407.     mouse.Button1Down:Connect(function()
  408.         re:FireServer('Button1Down')
  409.     end)
  410.     mouse.Button1Up:Connect(function()
  411.         re:FireServer('Button1Up')
  412.     end)
  413.     mouse.Button2Down:Connect(function()
  414.         re:FireServer('Button2Down')
  415.     end)
  416.     mouse.Button2Up:Connect(function()
  417.         re:FireServer('Button2Up')
  418.     end)
  419.    
  420.     runs.Heartbeat:Connect(function()
  421.         local mh = mouse.Hit
  422.         local mt = mouse.Target
  423.         if mh and mt then
  424.             re:FireServer('MouseInfo',mh,mt)
  425.         end
  426.     end)
  427.     re.OnClientEvent:Connect(function(arg1,arg2)
  428.         if arg1=='ChangeMouseIcon'then
  429.             mouse.Icon = arg2
  430.         end
  431.     end)
  432. else
  433.     print('Fat try again.')
  434. end
  435.             ]]
  436.             ,pchar)
  437.         return Remote
  438.     else
  439.         error('Best to actually put your character in the game.')
  440.     end
  441.    
  442.    
  443. end
  444. local RE = Get_Components_Of_Mouse(owner)
  445.  -- Function returns Remote event
  446.  
  447. if RE then
  448.     RE.OnServerEvent:Connect(On_OnServerEvent)
  449. end
  450.  
  451. --[[
  452.     .OSE() Arguments:
  453.     'KeyDown', <string: Key pressed down>
  454.     'KeyUp', <string: Key pressed up>
  455.     'Button1Down'
  456.     'Button1Up'
  457.     'Button2Down'
  458.     'Button2Up'
  459.     'MouseInfo', <CFrame: Mouse.Hit> , <Instance: Mouse.Target>
  460.    
  461.     :FireClient Goods:
  462.    
  463.     owner,'ChangeMouseIcon', <string: new mouse.Icon asset id>
  464. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement