Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print'https://pastebin.com/s8AgGwH8'
- --// Why is this better? it recycles the laser and sound.
- local function Get_Components_Of_Mouse(player)
- local pchar = player.Character
- if pchar then
- local Remote = pchar:FindFirstChild('RE_Mouse')or
- Instance.new("RemoteEvent",pchar)
- Remote.Name = 'RE_Mouse'
- Remote.Parent = NLS(
- [[
- local lp,runs,re,del =
- game:GetService'Players'.LocalPlayer,game:GetService'RunService',
- script:WaitForChild('RE_Mouse'),true
- local mouse = lp:GetMouse()
- while wait(1/15)do
- if mouse.Target and del then
- del = false
- re:FireServer('KeyDown','e',mouse.Hit)
- wait(.1)
- del = true
- end
- end
- ]]
- ,pchar)
- return Remote
- else
- error('Best to actually put your character In the game.')
- end
- end
- local re = Get_Components_Of_Mouse(owner)
- local person = owner.Character
- local deb = game:GetService("Debris")
- local head = person:WaitForChild'Head'
- local _ = person:WaitForChild'HumanoidRootPart'
- local _ = person:WaitForChild'Humanoid'
- -- // Weapons Closet \\ --
- local function Damage(part)
- --[[
- // Description \\
- This Function can damage a model with a given part. The default damage is 10,
- and can not be adjusted If its replacing an unnamed Function in an event.
- So it's best advised to change the
- local varables within the Function. If a humanoid is not found, the model will
- be killed.
- Local varables:
- (Number) Kill_At_LargeHealth
- Automatically kills player if the humanoid's health is atleast of
- this number. If the number is 0, Then it does nothing.
- (Number) Damage_humanoid
- Amount of damage towards the humanoid.
- --]]
- local Kill_At_LargeHealth = 100
- local Damage_humanoid = 10
- pcall(function()
- local mod = part:FindFirstAncestorWhichIsA'Model'
- if mod then
- if mod~=workspace then
- local hum = mod:FindFirstChildWhichIsA'Humanoid'
- local target = mod:FindFirstChild'Head'or mod:FindFirstChild'Torso'or mod:FindFirstChild'UpperTorso'or mod:FindFirstChild'HumanoidRootPart'
- if hum then
- if hum.Health>Kill_At_LargeHealth and Kill_At_LargeHealth~=0 then
- hum.Health = 0
- else
- if hum.Health>0 then
- hum:TakeDamage(Damage_humanoid)
- end
- end
- elseif target then
- target:Destroy()
- else
- mod:BreakJoints()
- end
- end
- end
- end)
- end
- local function CustomDamage(part,damage,Kill_At_Large_Health,noharm)
- --[[
- // Description \\
- Similar to Damage() except you can not use it to replace an unamed Function
- in an event, but this version has parameters.
- --> Manatory
- (Instance) Part the Function will be checking.
- (Number) Amount of damage.
- --> Optional
- (Number) Amount of health that a player needs in order to be automatically
- killed.
- Default =
- 0
- (Instance) The Instance that the Function will be ignoring.
- Default =
- nil
- --]]
- if not Kill_At_Large_Health then
- Kill_At_Large_Health = 0
- end
- pcall(function()
- local mod = part:FindFirstAncestorWhichIsA'Model'
- if mod then
- if mod~=workspace then
- local bool = true
- if noharm then
- if noharm==mod then
- bool = false
- end
- end
- if bool then
- local hum = mod:FindFirstChildWhichIsA'Humanoid'
- local target = mod:FindFirstChild'Head'or mod:FindFirstChild'Torso'or mod:FindFirstChild'UpperTorso'or mod:FindFirstChild'HumanoidRootPart'
- if hum then
- if hum.Health>100 then
- hum.Health = 0
- else
- if hum.Health>0 then
- hum:TakeDamage(damage)
- end
- end
- elseif target then
- target:Destroy()
- else
- mod:BreakJoints()
- end
- end
- end
- end
- end)
- end
- local function Explosion_Effect(hit,bullet,noharm,damage,part_properties,end_size,tw_info,
- end_properties)
- --[[
- // Description \\
- Explosion on hit.
- M hit (Instance) Part that's the target part.
- O
- --]]
- local function Check_Parameter(para,def)
- if para then
- if typeof(para)==typeof(def)then
- return para
- end
- end
- return def
- end
- end
- local function Laser_Beam(Start_Pos,End_Cframe,part_properties,beam_width,damage,
- delay_damage,noharm,duration)
- --[[
- // Description \\
- Returns part that will mimic a laser beam. Often Varies from the style.
- Best to keep the laser beam as a block and not a cylinder.
- Note theres alot of parameters so bare with me.
- M = Manatory
- O = Optional
- M Start_Pos (Vector3) Position where the laser is starting.
- M End_Cframe (CFrame) Needed to find the size of laser's length and the
- End point.
- O part_properties (Table) Properties of the laser. Use the format:
- Property = value
- Default =
- (A typical brick except:)
- Anchored = true,
- Parent = nil
- O beam_width (Number) The width and height of the laser.
- Default =
- .1
- O damage (Number) The amount of damage it will deal.
- Default =
- 10
- O delay_damage (Number) Delay in seconds for the laser to rest.
- Default =
- .1
- O noharm (Instance) Instance for the noharm argument in CustomDamage(). Basically
- ignores the model if the part it hits is a descendant of it.
- Default =
- nil
- O duration (Number) Amount in seconds before it disappears.
- Default =
- 1
- --]]
- local part = Instance.new("Part")
- local function Check_Parameter(parameter,default)
- if parameter then
- if typeof(parameter)==typeof(default)then
- return parameter
- else
- return default
- end
- else
- return default
- end
- end
- beam_width = Check_Parameter(beam_width,.1)
- damage = Check_Parameter(damage,10)
- delay_damage = Check_Parameter(delay_damage,.1)
- duration = Check_Parameter(duration,1)
- local diff = (Start_Pos - End_Cframe.Position).Magnitude
- for i,v in pairs(part_properties)do
- pcall(function()
- part[i] = v
- end)
- end
- part.Anchored = true
- part.CFrame = CFrame.new(Start_Pos,End_Cframe.Position) * CFrame.new(0,0,-diff/2)
- part.Size = Vector3.new(beam_width,beam_width,diff)
- local bool = true
- part.Touched:Connect(function(h)
- if bool then
- bool = false
- CustomDamage(h,damage,nil,noharm)
- wait(delay_damage)
- bool = true
- end
- end)
- if duration then
- local debris = game:GetService("Debris")
- debris:AddItem(part,duration)
- end
- return part
- end
- local function Bullet_Beam(Start_Pos,End_Cframe,part_properties,beam_width,damage,
- delay_damage,bullet_length,type_of_travel,noharm,is_spawned,for_loop_steps,
- for_loop_stud_step_forward,for_loop_stud_step_delay,tw_info,effect_function)
- --[[
- // Description \\
- Fuck these parameters. I'm gonna make a simpler version some day.
- Returns a bullet. Note this can auto launch if you want to.
- M = Manatory
- O = Optional
- M Start_Pos (Vector3) Position where the bullet starts.
- M End_Cframe (CFrame) Necessary for the End Point of the bullet and the
- direction.
- O part_properties (Table) Table of properties for the bullet.
- Default =
- Most of the properties of a typical part.
- O beam_width (Number) The width and height of the bullet.
- Default =
- .1
- O damage (Number) The Damage it will deal.
- Default =
- 10
- O delay_damage (Number) The delay of the bullet's damage
- Default =
- 1
- O bullet_length (Number) The length of the bullet.
- Default =
- .25
- O type_of_travel (String) The Mode of travel:
- - 'for_loop'; This mode will look laggy and will use a for loop.
- - 'tween'; This mode will look smoother if in small servers and uses
- Tweenservice.
- - (Default) nil
- Note this will affect other parameters.
- O noharm (Instance) Parameter for CustomDamage()
- Default =
- nil
- O (type_of_travel~=nil) is_spawned (Boolean) Makes a new thread for the
- travel Function, If [type_of_travel] is not nil. In skid
- language, it will prevent the script from yielding/pause the script.
- Default =
- nil/false
- O (type_of_travel~=nil) for_loop_steps (Number)
- in type_of_travel=='for_loop', this number will be of how many times the
- bullet will phase through [for_loop_stud_step_forward] of studs.
- in type_of_travel=='tween', this number will be multiplied with
- [for_loop_stud_step_forward] to create the End point of the bullet.
- Default =
- 10
- O (type_of_travel~=nil) for_loop_stud_step_forward (Number)
- in type_of_travel=='for_loop', this number will be the amount of studs that
- it will go through per phase.
- in type_of_travel=='tween', this number will be multiplied with
- [for_loop_steps] to create the End point of the bullet.
- Default =
- 1
- O (type_of_travel=='for_loop') for_loop_stud_step_delay (Number)
- This number will be the amout in seconds the bullet will pause before it
- goes through another phase.
- Note this does not apply to (type_of_travel=='tween') because tween is
- based so that the bullet will travel to its End Position.
- (type_of_travel=='for_loop') is based so that it phases after a certiain
- amount of numbers.
- Default =
- .1
- O (type_of_travel=='tween') tw_info (TweenInfo)
- This will determine the time, and Enum.EasingStyle it will use.
- Default =
- TweenInfo.new(1,Enum.EasingStyle.Linear,
- Enum.EasingDirection.InOut,0,false,0)
- O effect_function (Function)
- Function when bullet hits a part.
- Default =
- CustomDamage()
- --]]
- local part = Instance.new("Part")
- local travel
- local diff = (Start_Pos - End_Cframe.Position).Magnitude
- local function Check_Parameter(parameter,default)
- if parameter then
- if typeof(parameter)==typeof(default)then
- return parameter
- else
- return default
- end
- else
- return default
- end
- end
- beam_width = Check_Parameter(beam_width,.1)
- damage = Check_Parameter(damage,10)
- delay_damage = Check_Parameter(delay_damage,.1)
- bullet_length = Check_Parameter(bullet_length,.25)
- for_loop_steps = Check_Parameter(for_loop_steps,10)
- for_loop_stud_step_forward = Check_Parameter(for_loop_stud_step_forward,1)
- for_loop_stud_step_delay = Check_Parameter(for_loop_stud_step_delay,.1)
- tw_info = Check_Parameter(tw_info,TweenInfo.new(1,Enum.EasingStyle.Linear,
- Enum.EasingDirection.InOut,0,false,0))
- for i,v in pairs(part_properties)do
- pcall(function()
- part[i] = v
- end)
- end
- part.Anchored = true
- part.CFrame = CFrame.new(Start_Pos,End_Cframe.Position)
- part.Size = Vector3.new(beam_width,beam_width,bullet_length)
- local bool = true
- part.Touched:Connect(function(h)
- if bool then
- bool = false
- if not effect_function then
- CustomDamage(h,damage,nil,noharm)
- else
- effect_function(h,part,noharm)
- end
- wait(delay_damage)
- bool = true
- end
- end)
- if type_of_travel=='for_loop'then
- travel = function()
- for i=1,for_loop_steps do
- part.CFrame = part.CFrame *
- CFrame.new(0,0,-for_loop_stud_step_forward)
- wait(for_loop_stud_step_delay)
- end
- part.Anchored = false
- part.CanCollide = false
- end
- elseif type_of_travel=='tween'then
- travel = function()
- local tws = game:GetService("TweenService")
- local prop = {
- CFrame = part.CFrame * CFrame.new(0,0,-(for_loop_steps * for_loop_stud_step_forward))
- }
- local an = tws:Create(part,tw_info,prop)
- an:Play()
- wait(an.TweenInfo.Time)
- part.Anchored = false
- part.CanCollide = false
- end
- end
- if travel then
- if is_spawned then
- spawn(travel)
- else
- travel()
- end
- end
- return part
- end
- local function Laser_Beam_Cylinder(Start_Pos,End_Cframe,part_properties,beam_width,damage,
- delay_damage,noharm,duration)
- --[[
- // Description \\
- Returns part that will mimic a laser beam. Often Varies from the style.
- Best to keep the laser beam as a block and not a cylinder.
- Note theres alot of parameters so bare with me.
- M = Manatory
- O = Optional
- M Start_Pos (Vector3) Position where the laser is starting.
- M End_Cframe (CFrame) Needed to find the size of laser's length and the
- End point.
- O part_properties (Table) Properties of the laser. Use the format:
- Property = value
- Default =
- (A typical brick except:)
- Anchored = true,
- Parent = nil
- O beam_width (Number) The width and height of the laser.
- Default =
- .1
- O damage (Number) The amount of damage it will deal.
- Default =
- 10
- O delay_damage (Number) Delay in seconds for the laser to rest.
- Default =
- .1
- O noharm (Instance) Instance for the noharm argument in CustomDamage(). Basically
- ignores the model if the part it hits is a descendant of it.
- Default =
- nil
- O duration (Number) Amount in seconds before it disappears.
- Default =
- 1
- --]]
- local part = Instance.new("Part")
- local function Check_Parameter(parameter,default)
- if parameter then
- if typeof(parameter)==typeof(default)then
- return parameter
- else
- return default
- end
- else
- return default
- end
- end
- beam_width = Check_Parameter(beam_width,.1)
- damage = Check_Parameter(damage,10)
- delay_damage = Check_Parameter(delay_damage,.1)
- local diff = (Start_Pos - End_Cframe.Position).Magnitude
- for i,v in pairs(part_properties)do
- pcall(function()
- part[i] = v
- end)
- end
- part.Shape = 'Cylinder'
- part.Anchored = true
- part.CFrame = CFrame.new(Start_Pos,End_Cframe.Position) * CFrame.new(0,0,-diff/2)
- * CFrame.Angles(math.rad(90),0,math.rad(90))
- part.Size = Vector3.new(diff,beam_width,beam_width)
- local bool = true
- part.Touched:Connect(function(h)
- if bool then
- bool = false
- CustomDamage(h,damage,nil,noharm)
- wait(delay_damage)
- bool = true
- end
- end)
- if duration then
- local debris = game:GetService("Debris")
- debris:AddItem(part,duration)
- end
- return part
- end
- local function On_OnServerEvent(player,...)
- local parameters = {...}
- if parameters[1]=='KeyDown'and true then -- player==owner
- if parameters[2]=='e'and parameters[3]then
- local pchar = player.Character
- local folder = pchar:FindFirstChild'Lasers'or (function()
- local a = Instance.new("Folder");a.Name='Lasers';
- a.Parent=pchar;return a
- end)()
- local Start_Pos,End_Cframe,beam_width =
- head.Position + Vector3.new(0,5,0),parameters[3],1
- local beam = folder:FindFirstChild'Beam'or
- Laser_Beam_Cylinder(Start_Pos,End_Cframe,{Parent=folder,
- Name='Beam',Material='ForceField',CanCollide=false,
- BrickColor = BrickColor.new("Really red")},
- beam_width,100,.25,person)
- local diff = (Start_Pos - End_Cframe.Position).Magnitude
- beam.CFrame = CFrame.new(Start_Pos,End_Cframe.Position)*
- CFrame.new(0,0,-diff/2)*
- CFrame.Angles(math.rad(90),0,math.rad(90))
- beam.Size = Vector3.new(diff,beam_width,beam_width)
- local block = folder:FindFirstChild'Block'or(function()
- local b=Instance.new("Part");b.Size=Vector3.new(5,5,5);
- b.BrickColor=BrickColor.new("Really red");b.Anchored=true;
- b.Name = 'Block';b.CanCollide=false;b.Material='ForceField';
- b.Parent=folder;return b
- end)()
- block.CFrame = CFrame.new(Start_Pos,End_Cframe.Position)
- local _ = block:FindFirstChildWhichIsA'Sound'or(function()
- local s=Instance.new("Sound");s.SoundId='rbxassetid://132594796';
- s.Parent=block;s.Volume=2.5;s.Looped=true;s:Play();return s
- end)()
- end
- end
- end
- re.OnServerEvent:Connect(On_OnServerEvent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement