Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(1)
- local ContentProvider = Game:GetService("ContentProvider")
- local Tool = script.Parent;
- local pewsound
- local pewsound2
- local bangsound
- local bangsound2
- local cam
- local ggui
- local lon = false
- enabled = true
- automatichold = false
- dmged = false
- shotgun = false
- equipped = false
- overheated = false
- isZoom = false
- MaxDist = 1000
- local mouseicons = {70288578, 70288572, 70288578}
- local metalhit = {154441338, 154441342, 154441355}
- local FireTrack = script.Parent.Fire
- local ReloadTrack = script.Parent.Reload
- local Idle = script.Parent.Idle
- cam = game.Workspace.CurrentCamera
- -----------------------------------------ONLY EDIT THESE VALUES!!!!!-----------------------------------------
- -----!Instructions!-----
- --Make sure you have a part in the gun named Barrel, it is where the raycast will shoot from.--
- --Just place this script into any gun and edit the values below.--
- --Editting anything else will risk breaking it.--
- ------------------------
- local function LoadAssets(AssetList)
- -- Takes an asset list and preloads it. Will not wait for them to load.
- for _, AssetId in pairs(AssetList) do
- ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. AssetId)
- end
- end
- LoadAssets({144884872, 2434541, 5133543, 2423433, 41143243, 2453865, 21433365, 2154549})
- ------------------------
- Damage = 29
- SPS = 15 -- Shots Per Second, gives a limit of how fast the gun shoots.
- Recoil = 4 -- [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 = "Cool yellow" -- Any Brickcolor will work.
- Flash = true
- --------------------------------------------------------------------------------------------------------
- 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
- GroupID = 9999
- function recoiltool1()
- script.Parent.GripForward = Vector3.new(-0.208, -0.091, -0.974)
- script.Parent.GripPos = Vector3.new(0.018, -0.37, 0.271)
- script.Parent.GripRight = Vector3.new(0.978, -0.018, -0.207)
- script.Parent.GripUp = Vector3.new(-0.001, 0.996, -0.093)
- ----------
- end
- 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
- 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 getty(hitted)
- local IDMH = metalhit[math.random(1,#metalhit)]
- if hitted:IsA("BasePart") and hitted.Name == "Metal" then
- local mhs = Instance.new("Sound")
- mhs.SoundId = "http://www.roblox.com/asset?id=" .. IDMH
- mhs.Volume = 0.4
- mhs.Parent = hitted
- mhs:Play()
- game:GetService('Debris'):AddItem(mhs, 1)
- end
- if hitted:IsA("BasePart") and hitted.Name == "Glass" or hitted.Name == "Window" or hitted.Name == "DestructionPart" and hitted.Transparency > 0 then
- local gbs = Instance.new("Sound")
- gbs.SoundId = "http://www.roblox.com/asset/?id=144884907"
- gbs.Volume = 0.5
- gbs.Parent = hitted
- gbs:Play()
- game:GetService('Debris'):AddItem(gbs, 1)
- hitted:Destroy()
- end
- if hitted:IsA("BasePart") and hitted.Name == "Wheel" or hitted.Name == "Tire" then
- local tps = Instance.new("Sound")
- tps.SoundId = "http://www.roblox.com/asset/?id=160248280"
- tps.Volume = 0.5
- tps.Parent = hitted
- tps:Play()
- hitted.CanCollide = false
- game:GetService('Debris'):AddItem(tps, 1)
- end
- if hitted:IsA("BasePart") and hitted.Name == "Head" then
- local bhs = Instance.new("Sound")
- bhs.SoundId = "http://www.roblox.com/asset/?id=144884872"
- bhs.Volume = 0.6
- bhs.Pitch = math.random(90,110)/100
- bhs.Parent = hitted
- bhs:Play()
- local bhe = Instance.new("Fire")
- bhe.Color = BrickColor.new("Really red").Color
- bhe.SecondaryColor = BrickColor.new("Really red").Color
- bhe.Heat = 0
- bhe.Size = 4
- bhe.Name = "BloodEfect"
- bhe.Parent = hitted
- game:GetService('Debris'):AddItem(bhe, 0.6)
- game:GetService('Debris'):AddItem(bhs, 1)
- 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
- getty(Part)
- if hathum ~= nil and hat:IsA("Hat") and AntiGH(hathum.Parent, script.Parent.Parent) then
- hathum:TakeDamage(Damage/1)
- Part.Parent = game.Workspace
- Part:BreakJoints()
- --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*3)
- end
- hum:TakeDamage(Damage)
- c.Parent = hum
- game.Debris:AddItem(c,1.5)
- end
- end
- end
- function onButton1Down(mouse)
- FireTrack:Play()
- if script.Parent.Ammo.Value == 0 then
- else
- if GunType == 0 then
- if (not enabled) then return end
- enabled = false
- mouse.Icon = "http://www.roblox.com/asset/?id=".. mouseicons[math.random(1,3)]-- WIP151
- local cam_rot = cam.CoordinateFrame - cam.CoordinateFrame.p
- local cam_scroll = (cam.CoordinateFrame.p - cam.Focus.p).magnitude
- local ncf = CFrame.new(cam.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ(0.003, 0.004, 0)
- cam.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll)
- --WPN_UP
- LaserShoot(mouse)
- if Flash then
- script.Parent.Barrel.Light.Light.Visible = true
- script.Parent.Barrel.PointLight.Enabled = true
- script.Parent.Barrel.Smoke.Enabled = true
- end
- script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
- wait(0.01)
- if Flash then
- script.Parent.Barrel.Light.Light.Visible = false
- script.Parent.Barrel.PointLight.Enabled = false
- script.Parent.Barrel.Smoke.Enabled = false
- end
- wait(1/SPS)
- --WPN_DOWN
- mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
- 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 script.Parent.Parent:findFirstChild("Humanoid").Health == 0 then script.Parent:Remove() end
- enabled = false
- mouse.Icon = "http://www.roblox.com/asset/?id=".. mouseicons[math.random(1,3)]-- WIP151
- local cam_rot = cam.CoordinateFrame - cam.CoordinateFrame.p
- local cam_scroll = (cam.CoordinateFrame.p - cam.Focus.p).magnitude
- local ncf = CFrame.new(cam.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ(0.005, 0.003, 0)
- cam.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll)
- LaserShoot(mouse)
- if Flash then
- script.Parent.Barrel.Light.Light.Visible = true
- end
- script.Parent.Ammo.Value = script.Parent.Ammo.Value - 1
- wait(0.01)
- if Flash then
- script.Parent.Barrel.Light.Light.Visible = false
- end
- wait(1/SPS)
- mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
- --WPN_DOWN
- enabled = true
- 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(1,1,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)
- pewsound = script.Parent.Handle:FindFirstChild("Fire")
- if pewsound then
- pewsound.Pitch = math.random(90,110)/100
- pewsound:Play()
- end --Brick created. Moving on to next part
- 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(.04,enddist,.04)
- else
- P.CFrame = CFrame.new(EndPos, SPos) * CFrame.new(0,0,-MaxDist/2) * CFrame.Angles(math.rad(90),0,0)
- m.Scale = Vector3.new(.04,MaxDist,.04)
- 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 onKeyDown(key, mouse)
- if key:lower() == "r" then
- if script.Parent.Ammo.Value ~= script.Parent.MaxAmmo.Value then
- reloadsound = script.Parent.Handle:FindFirstChild("Reload")
- if reloadsound then
- script.Parent.Reload:Play()
- reloadsound:Play()
- end
- enabled = false
- script.Parent.VisibleB.Value = true
- script.Parent.StringValue.Value = "Reloading"
- mouse.Icon = "http://www.roblox.com/asset/?id=70288599"
- script.Parent.Handle.RLD:play()
- repeat script.Parent.StringValue.Value = "Reloading" wait(0.3) script.Parent.Ammo.Value = script.Parent.Ammo.Value + 3 script.Parent.StringValue.Value = "Reloading" until script.Parent.Ammo.Value >= script.Parent.MaxAmmo.Value
- script.Parent.Ammo.Value = script.Parent.MaxAmmo.Value
- wait(0.2)
- script.Parent.VisibleB.Value = false
- enabled = true
- mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
- end
- end
- if key:lower() == "l" then
- lon = not lon
- script.Parent.FLight.Sound:Play()
- if lon == true then
- script.Parent.FLight.Light.Enabled = true
- script.Parent.FLight.SpotLight.Enabled = true
- elseif lon == false then
- script.Parent.FLight.Light.Enabled = false
- script.Parent.FLight.SpotLight.Enabled = false
- end
- end
- end
- function onEquipped(mouse)
- equipped = true
- script.Parent.Handle.Out1:Play()
- if mouse == nil then
- print("Mouse not found")
- return
- end
- mouse.Icon = "http://www.roblox.com/asset/?id=70288585"
- 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
- script.Parent.Handle.In1:Play()
- script.Parent.Handle.In2:Play()
- automatichold = false
- end
- script.Parent.Equipped:connect(onEquipped)
- script.Parent.Unequipped:connect(onUnequipped)
- while true do wait()
- if script.Parent.Ammo.Value == 0 then
- script.Parent.VisibleB.Value = true
- script.Parent.StringValue.Value = "Reload"
- end
- if GunType == 1 then
- script.Parent.ModeText.Value = "Auto"
- else
- script.Parent.ModeText.Value = "Semi"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment