Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(1)
- local Tool = script.Parent;
- local pewsound
- local bangsound
- local cam
- local ggui
- local AlertCarry = Tool.AlertCarry
- --
- enabled = true
- automatichold = false
- dmged = false
- shotgun = false
- equipped = false
- overheated = false
- isZoom = false
- -----------------------------------------------------------------------------ONLY EDIT THESE VALUES!!!!!
- -----!Instructions!-----
- --Make sure you have a part in the gun named Barrel, it is where the laser will shoot from.--
- --Just place this script into any gun and edit the values below.--
- --Don't edit anything else or risk breaking it.--
- ------------------------
- Damage = math.random(25,27)
- SPS = 9 -- Shots Per Second, gives a limit of how fast the gun shoots.
- Recoil = 10 -- [1-10] [1 = Minigun, 10 = Sniper]
- WallShoot = false -- Shoots through walls.
- GH = false -- [True = RB can't hurt RB.] [False = RB can hurt RB.]
- BulletColor = "New Yeller" -- Any Brickcolor will work.
- --------------------------------------------------------------------------------------------------------
- local zm = Instance.new("Part")
- zm.Name = "ZoomZM"
- zm.Anchored = true
- zm.Transparency = 1
- zm.Size = Vector3.new(1,1,1)
- zm.CanCollide = false
- GunType = 0
- --[[local gui = Instance.new("ScreenGui")
- local bg = Instance.new("Frame",gui)
- local bar = Instance.new("Frame",bg)
- local bvl = Instance.new("ImageLabel", bg)
- bvl.Name = "Bevel"
- bvl.BackgroundTransparency = 1
- bvl.Image = "http://www.roblox.com/asset/?id=56852431"
- bvl.Size = UDim2.new(1,0,1,0)
- bg.Name = "Back"
- bar.Name = "Charge"
- bar.BackgroundColor3 = Color3.new(200/255,0/255,0/255)
- bg.BackgroundColor3 = Color3.new(200/255,200/255,200/255)
- bg.Size = UDim2.new(0,10,0,-100)
- bg.Position = UDim2.new(0,5,0,500)
- bar.Size = UDim2.new(0,4,-1,0)
- bar.Position = UDim2.new(0,3,1,0)
- ggui = gui:Clone()
- ggui.Name = "GunGui"
- ggui.Back.Charge.Size = UDim2.new(0,4,-(script.Charge.Value/100),0)]]
- GroupID = 5520
- function AntiGH(char1,char2)
- if GH then
- local plyr1 = game.Players:findFirstChild(char1.Name)
- local plyr2 = game.Players:findFirstChild(char2.Name)
- if plyr1 and plyr2 then
- if plyr1:IsInGroup(GroupID) and plyr2:IsInGroup(GroupID) then
- return false
- end
- end
- return true
- elseif not GH then
- return true
- end
- end
- MaxDist = 1000
- function RayCast(Start,End,Ignore)
- if WallShoot then
- ray1 = Ray.new(Start, End.unit * 999.999)
- local Part1, TempPos = Workspace:FindPartOnRay(ray1,Ignore)
- ray2 = Ray.new(TempPos, End.unit * 999.999)
- local Part2, EndPos = Workspace:FindPartOnRay(ray2,Part1)
- return Part1, Part2, EndPos
- elseif not WallShoot then
- ray = Ray.new(Start, End.unit * 999.999)
- return Workspace:FindPartOnRay(ray,Ignore)
- end
- end
- function DmgPlr(Part)
- if Part ~= nil then
- local c = Instance.new("ObjectValue")
- c.Name = "creator"
- c.Value = game.Players:findFirstChild(script.Parent.Parent.Name)
- local hum = Part.Parent:findFirstChild("Humanoid")
- local hathum = Part.Parent.Parent:findFirstChild("Humanoid")
- local hat = Part.Parent
- if hathum ~= nil and hat:IsA("Hat") and AntiGH(hathum.Parent, script.Parent.Parent) then
- hathum:TakeDamage(Damage/3)
- Part.Parent = game.Workspace
- Part.CFrame = CFrame.new(Part.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)))
- hat:Remove()
- c.Parent = hathum
- game.Debris:AddItem(c,1.5)
- elseif hum ~= nil and AntiGH(hum.Parent, script.Parent.Parent) then
- if Part.Name == "Head" then
- hum:TakeDamage(Damage*2)
- end
- hum:TakeDamage(Damage)
- c.Parent = hum
- game.Debris:AddItem(c,1.5)
- end
- end
- end
- function onButton1Down(mouse)
- if AlertCarry.Value == false then
- if script.Parent.Ammo.Value == 0 then
- else
- if GunType == 0 then
- if (not enabled) then return end
- enabled = false
- LaserShoot(mouse)
- script.Parent.Barrel.Light.Light.Visible = true
- script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
- wait(0.01)
- script.Parent.Barrel.Light.Light.Visible = false
- wait(1/SPS)
- enabled = true
- elseif GunType == 1 then
- automatichold = true
- while automatichold == true and script.Parent.Ammo.Value ~= 0 do wait()
- if (not enabled) then return end
- if AlertCarry.Value == false then
- enabled = false
- LaserShoot(mouse)
- script.Parent.Barrel.Light.Light.Visible = true
- script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
- wait(0.01)
- script.Parent.Barrel.Light.Light.Visible = false
- wait(1/SPS)
- enabled = true
- end
- end
- end
- end
- end
- end
- function LaserShoot(mouse)
- hit = mouse.Hit.p
- local StartPos = script.Parent.Barrel.CFrame.p
- local rv = (StartPos-hit).magnitude/(Recoil * 20)
- local rcl = Vector3.new(math.random(-rv,rv),math.random(-rv,rv),math.random(-rv,rv))
- aim = hit + rcl
- local P = Instance.new("Part")
- P.Name = "Bullet"
- P.formFactor = 3
- P.BrickColor = BrickColor.new(BulletColor)
- P.Size = Vector3.new(0.1,0.1,0.1)
- P.Anchored = true
- P.CanCollide = false
- P.Transparency = 1
- P.Parent = script.Parent.Parent
- local m = Instance.new("CylinderMesh")
- m.Name = "Mesh"
- m.Parent = P
- local c = Instance.new("ObjectValue")
- c.Name = "creator"
- c.Value = game.Players:findFirstChild(script.Parent.Parent.Name)
- script.Fire:Play()
- local SPos = script.Parent.Barrel.CFrame.p
- if WallShoot then
- local Part1, Part2, EndPos = RayCast(SPos, (aim-SPos).unit * 999, script.Parent.Parent)
- DmgPlr(Part1)
- DmgPlr(Part2)
- if Part1 and Part2 then
- local enddist = (EndPos-SPos).magnitude
- P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0,0,-enddist/2) * CFrame.Angles(math.rad(90),0,0)
- m.Scale = Vector3.new(.2,enddist,.2)
- else
- P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0,0,-MaxDist/2) * CFrame.Angles(math.rad(90),0,0)
- m.Scale = Vector3.new(.2,MaxDist,.2)
- end
- elseif not WallShoot then
- local Part, Pos = RayCast(SPos, (aim-SPos).unit * 999, script.Parent.Parent)
- DmgPlr(Part)
- if Part then
- local dist = (Pos-SPos).magnitude
- P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0,0,-dist/2) * CFrame.Angles(math.rad(90),0,0)
- m.Scale = Vector3.new(.1,dist,.1)
- else
- P.CFrame = CFrame.new(Pos, SPos) * CFrame.new(0,0,-MaxDist/2) * CFrame.Angles(math.rad(90),0,0)
- m.Scale = Vector3.new(.1,MaxDist,.1)
- end
- end
- game.Debris:AddItem(P,.1)
- end
- function onButton1Up(mouse)
- automatichold = false
- end
- function onEquippedLocal(mouse)
- mouse.Icon = ""
- mouse.KeyDown:connect(onKeyDown)
- end
- function defaultrifle()
- torso = Tool.Parent:FindFirstChild("Torso")
- if torso ~= nil then
- torso.weld1.C1 = CFrame.new(-0.25, -0.2, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(350), 0, math.rad(-90))
- torso.weld2.C1 = CFrame.new(-1, 0.3, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
- end
- end
- function defaultpistol()
- torso = Tool.Parent:FindFirstChild("Torso")
- if torso ~= nil then
- torso.weld1.C1 = CFrame.new(-0.25, -0.2, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(350), 0, math.rad(-90))
- torso.weld2.C1 = CFrame.new(-1, 0.3, 0.35) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-15), 0)
- end
- end
- function holster()
- torso = Tool.Parent:FindFirstChild("Torso")
- if torso ~= nil then
- torso.weld1.C1 = CFrame.new(0.5,0,.5) * CFrame.fromEulerAnglesXYZ(math.rad(315), 0, math.rad(-40))
- torso.weld2.C1 = CFrame.new(-.8, -0.6, -0.5) * CFrame.fromEulerAnglesXYZ(math.rad(-40), math.rad(-60), 0)
- end
- end
- function onKeyDown(key, mouse)
- if key:lower() == "r" then
- if script.Parent.Ammo.Value ~= script.Parent.MaxAmmo.Value then
- script.Reload:Play()
- enabled = false
- repeat wait(0.05) script.Parent.Ammo.Value = script.Parent.Ammo.Value + 3 until script.Parent.Ammo.Value >= script.Parent.MaxAmmo.Value
- script.Parent.Ammo.Value = script.Parent.MaxAmmo.Value
- enabled = true
- end
- end
- if key:lower() == "m" then
- if GunType == 1 then
- GunType = 0
- Recoil = 10
- else
- GunType = 1
- Recoil = 8
- end
- end
- if key:lower() == "e" then
- if AlertCarry.Value == false then
- holster()
- AlertCarry.Value = true
- else
- defaultrifle()
- AlertCarry.Value = false
- end
- end
- end
- function onEquipped(mouse)
- equipped = true
- if mouse == nil then
- print("Mouse not found")
- return
- end
- mouse.Icon = "http://www.roblox.com/asset/?id=70405991"
- mouse.Button1Down:connect(function() onButton1Down(mouse) end)
- mouse.Button1Up:connect(function() onButton1Up(mouse) end)
- mouse.KeyDown:connect(function(key) onKeyDown(key, mouse) end)
- end
- function onUnequipped(mouse)
- equipped = false
- automatichold = false
- end
- script.Parent.Equipped:connect(onEquipped)
- script.Parent.Unequipped:connect(onUnequipped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement