Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plr,char,hum,root
- plr = owner
- char = plr.Character
- hum = char:FindFirstChildOfClass("Humanoid")
- root = char:FindFirstChild("HumanoidRootPart")
- head = char:FindFirstChild("Head")
- Tool0 = Instance.new("Tool")
- Part1 = Instance.new("Part")
- SpecialMesh2 = Instance.new("SpecialMesh")
- Tool0.Name = "G18"
- Tool0.Parent = nil
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.CFrame = CFrame.new(-9.40400028, 0.49000001, -11.9640007, -1, 0, 8.74227766e-08, 0, 1, 0, -8.74227766e-08, 0, -1)
- Part1.Orientation = Vector3.new(0, 180, 0)
- Part1.Position = Vector3.new(-9.40400028, 0.49000001, -11.9640007)
- Part1.Rotation = Vector3.new(-180, 0, -180)
- Part1.Size = Vector3.new(1.44400001, 0.980000019, 0.231999993)
- Part1.Anchored = true
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.CanCollide = false
- Part1.TopSurface = Enum.SurfaceType.Smooth
- SpecialMesh2.Parent = Part1
- SpecialMesh2.MeshId = "rbxassetid://543260475"
- SpecialMesh2.Scale = Vector3.new(0.0710000023, 0.0710000023, 0.0710000023)
- SpecialMesh2.TextureId = "rbxassetid://543261418"
- SpecialMesh2.MeshType = Enum.MeshType.FileMesh
- local tool,handle
- tool = Tool0
- tool.CanBeDropped = false
- handle = tool:FindFirstChild("Handle")
- for i,v in pairs(tool:GetChildren()) do
- if v:IsA("BasePart") then
- v.Anchored = false
- v.CanCollide = false
- v.Locked = true
- if v ~= handle then
- local weld = Instance.new("Weld")
- weld.Part0 = handle
- weld.Part1 = v
- weld.C0 = handle.CFrame:Inverse()
- weld.C1 = v.CFrame:Inverse()
- weld.Parent = v
- else
- v.CanCollide = true
- end
- end
- end
- tool.Parent = plr:FindFirstChildOfClass("Backpack")
- local grips = {
- shooting = CFrame.new(-0.335572511, -0.202204779, -0.00730848266, 1.17396892e-08, 0.17555213, -0.984470129, -2.09343809e-09, 0.984470129, 0.17555213, 1, 0, 1.19248806e-08),
- equipped = CFrame.new(-0.331445694, -0.158765793, -0.00730848266, 1.19248806e-08, 0, -1, 0, 1, 0, 1, 0, 1.19248806e-08),
- }
- tool.Grip = grips.equipped
- NLS([[
- local plr,char,hum,root,head
- function get_char()
- plr = game:GetService("Players").LocalPlayer
- repeat wait() until plr.Character and plr.Character.Parent
- char = plr.Character
- hum = char:FindFirstChild("Humanoid")
- root = char:FindFirstChild("HumanoidRootPart")
- head = char:FindFirstChild("Head")
- if not hum or 0 >= hum.Health then
- get_char()
- end
- end
- get_char()
- local mouse = plr:GetMouse()
- local uis = game:GetService("UserInputService")
- local remote = game:GetService("ReplicatedStorage"):WaitForChild('gun_server_remote')
- local tool = script.Parent
- local camera = workspace.CurrentCamera
- local aim_type = 0
- local has_scope = false
- local original_sens = game:GetService("UserInputService").MouseDeltaSensitivity
- local tool,handle
- tool = script.Parent
- handle = tool:WaitForChild("Handle")
- local grips = {
- shooting = CFrame.new(-0.335572511, -0.202204779, -0.00730848266, 1.17396892e-08, 0.17555213, -0.984470129, -2.09343809e-09, 0.984470129, 0.17555213, 1, 0, 1.19248806e-08),
- equipped = CFrame.new(-0.331445694, -0.158765793, -0.00730848266, 1.19248806e-08, 0, -1, 0, 1, 0, 1, 0, 1.19248806e-08),
- }
- tool.Grip = grips.equipped
- local bulletfire = 1
- local firemodes = {
- 'i2',
- 'i1',
- 'i3'
- }
- local fmid = 0
- local firemode = 1 -- 1 = semi, 2 = auto, 3 = burst
- local shootwait = 0.04/bulletfire
- local boltwait = 1.5
- local recoil_power = 1.3
- local needcool = false
- local boltaction = false
- local boltaction2 = false
- local max_tot_ammo = 1/0
- local tot_ammo = max_tot_ammo
- local max_ammo = 18
- local ammo = max_ammo
- local recoil = 0
- local lastshot = 0
- local using = false
- local equipped = false
- local op = false
- local junk = workspace:WaitForChild('junk',1) or workspace
- local hud = nil
- local can_scope = true
- local shooting = false
- --script.Parent = nil
- if not script:FindFirstChild('set') then
- local set = Instance.new("NumberValue",script)
- set.Name = 'set'
- local n1 = Instance.new("NumberValue",script)
- n1.Name = 'ammo'
- n1.Value = max_ammo
- local n2 = Instance.new("NumberValue",script)
- n2.Name = 'total_ammo'
- n2.Value = max_tot_ammo
- else
- ammo = script:FindFirstChild('ammo').Value
- tot_ammo = script:FindFirstChild('total_ammo').Value
- end
- local bullettype = 1
- local bullettypes = {
- [1] = { -- small (smgs, pistols)
- mesh = 'http://www.roblox.com/asset/?id=95387759',
- texture = 'http://www.roblox.com/asset/?id=95387789',
- scale = Vector3.new(1.8, 1.8, 1.8),
- size = Vector3.new(0.12, 0.12, 0.21)
- },
- [2] = { -- medium (rifles)
- mesh = 'http://www.roblox.com/asset/?id=95392019',
- texture = 'http://www.roblox.com/asset/?id=95391833',
- scale = Vector3.new(0.9, 0.9, 0.9),
- size = Vector3.new(0.12, 0.12, 0.192)
- },
- [3] = { -- big (snipers, big bois)
- mesh = 'http://www.roblox.com/asset/?id=94295100',
- texture = 'http://www.roblox.com/asset/?id=94287792',
- scale = Vector3.new(2.4, 2.4, 2.4),
- size = Vector3.new(0.12, 0.12, 0.372)
- },
- [4] = { -- medium (shotguns)
- mesh = 'http://www.roblox.com/asset/?id=94248124',
- texture = 'http://www.roblox.com/asset/?id=94219470',
- scale = Vector3.new(0.45, 0.45, 0.45),
- size = Vector3.new(0.12, 0.12, 0.234)
- },
- }
- local libruary = {
- ['wizz'] = {342190005, 342190012, 342190017, 342190024},
- ['crackSmall'] = {873119768, 873119788, 873119811, 873119845, 873119886, 873119904},
- ['crackBig'] = {873119597, 873119653, 873119679, 873119703, 873119724, 873119744},
- ['whizz'] = {873121840, 873121858, 873121876, 873121896, 873121913, 873121936},
- ['woodhit'] = {342204157, 342204164, 342204170, 342204175, 871705143, 871705174}, --871705195, 871705217, 871705237, 871705264
- ['stonehit'] = {871701076, 871701134, 871701190, 871701241, 871701297, 871701346},
- ['metalhit'] = {871704182, 871704259, 871704297, 871704329, 871704362, 871704395},
- ['grasshit'] = {871709869, 871709832, 871709789, 871709755, 871709708, 871709643},
- ['impact'] = {525720625},
- }
- local gundata = {
- ['AK-47'] = {
- reload_s = 'rbxassetid://3742928054',
- shoot_s = 'rbxassetid://168436671',
- },
- ['M4A1-S'] = {
- reload_s = 'rbxassetid://2232695010',
- shoot_s = 'rbxassetid://4642718673',
- },
- ['G18'] = {
- reload_s = 'rbxassetid://2232697419',
- shoot_s = 'rbxassetid://240718012',
- },
- ['BFG-50'] = {
- reload_s = 'rbxassetid://2775805505',
- shoot_s = 'rbxassetid://590136707',
- },
- ['SSG-08'] = {
- reload_s = 'rbxassetid://4649193317',
- shoot_s = 'rbxassetid://4649186576',
- },
- }
- gundata = gundata[tool.Name]
- local equip = Instance.new("Sound")
- equip.SoundId = 'rbxassetid://769464514'
- equip.Volume = 0.8
- equip.Parent = handle
- local reload_s = Instance.new("Sound")
- reload_s.SoundId = gundata.reload_s
- reload_s.Volume = 0.7
- reload_s.Parent = handle
- local wbreak_s = Instance.new("Sound")
- wbreak_s.SoundId = "rbxassetid://627558611"
- wbreak_s.Volume = 0.7
- wbreak_s.Parent = handle
- local empty_s = Instance.new("Sound")
- empty_s.SoundId = 'rbxassetid://132464034'
- empty_s.Volume = 0.7
- empty_s.Parent = handle
- local mode_s = Instance.new("Sound")
- mode_s.SoundId = 'rbxassetid://4581285291'
- mode_s.Volume = 0.7
- mode_s.Parent = handle
- local shoot_s = Instance.new("Sound")
- shoot_s.Name = 'shoot'
- shoot_s.SoundId = gundata.shoot_s
- shoot_s.Volume = 1
- shoot_s.Parent = handle
- local effect_part = Instance.new("Part")
- local smoke = Instance.new("ParticleEmitter")
- local flash = Instance.new("ParticleEmitter")
- local light = Instance.new("PointLight")
- effect_part.Name = "effect"
- effect_part.Parent = tool
- effect_part.CFrame = CFrame.new(-14.3099976, 2.64201403, -6.57999992)
- effect_part.Transparency = 1
- effect_part.Size = Vector3.new(0.100000001, 0.100000001, 0.100000001)
- effect_part.BottomSurface = Enum.SurfaceType.Smooth
- effect_part.CanCollide = false
- effect_part.TopSurface = Enum.SurfaceType.Smooth
- smoke.Name = "smoke"
- smoke.Parent = effect_part
- smoke.Speed = NumberRange.new(5, 7)
- smoke.Rotation = NumberRange.new(0, 360)
- smoke.Color = ColorSequence.new(Color3.new(0.27451, 0.27451, 0.27451),Color3.new(0.27451, 0.27451, 0.27451))
- smoke.Enabled = false
- smoke.LightEmission = 0.10000000149012
- smoke.Texture = "http://www.roblox.com/asset/?id=244514423"
- smoke.Transparency = NumberSequence.new(0.60000002384186,1)
- smoke.Size = NumberSequence.new(0.99999964237213,3)
- smoke.Lifetime = NumberRange.new(1.25, 1.5)
- smoke.Rate = 100
- smoke.RotSpeed = NumberRange.new(10, 10)
- smoke.SpreadAngle = Vector2.new(15, 15)
- smoke.VelocitySpread = 15
- flash.Name = "flash"
- flash.Parent = effect_part
- flash.Speed = NumberRange.new(0, 0)
- flash.Rotation = NumberRange.new(0, 90)
- flash.Color = ColorSequence.new(Color3.new(1, 1, 0.498039),Color3.new(1, 1, 0.498039))
- flash.Enabled = false
- flash.LightEmission = 1
- flash.Texture = "http://www.roblox.com/asset/?id=3419963"
- flash.Transparency = NumberSequence.new(0.75,1)
- flash.Size = NumberSequence.new(0.20000000298023,0.20000000298023)
- flash.Lifetime = NumberRange.new(0.050000000745058, 0.075000002980232)
- flash.Speed = NumberRange.new(50,50)
- flash.Rate = 1000
- light.Name = "light"
- light.Parent = effect_part
- light.Color = Color3.new(1, 1, 0.498039)
- light.Enabled = false
- light.Range = 6
- light.Brightness = 10
- light.Shadows = true
- local weld = Instance.new("Weld")
- weld.Part0 = handle
- weld.Part1 = effect_part
- weld.C0 = weld.C0 * CFrame.new((handle.Size.X/2),0.35,0) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(-90))
- weld.Parent = effect_part
- local chamber_part = tool:FindFirstChild("chamber") or handle
- local mag = tool:FindFirstChild("Mag")
- if not mag then
- mag = Instance.new("Part")
- mag.Name = 'gun mag'
- mag.Size = Vector3.new(0.48, 0.8, 0.14)
- mag.Color = handle.Color
- mag.CFrame = handle.CFrame * CFrame.new(0.1,-0.1,0)
- end
- function change_firemode()
- mode_s:Play()
- fmid = fmid + 1
- if fmid > #firemodes then
- fmid = 1
- end
- firemode = tonumber(string.sub(firemodes[fmid],2,2))
- if firemode == 3 then
- bulletfire = 3
- else
- bulletfire = 1
- end
- end
- change_firemode()
- function togglebolt(mode)
- if mode == 'back' then
- for i,v in pairs(tool:GetChildren()) do
- if v.Name == 'Bolt' then
- v.Transparency = 1
- elseif v.Name == 'BoltBack' then
- v.Transparency = 0
- end
- end
- elseif mode == 'normal' then
- for i,v in pairs(tool:GetChildren()) do
- if v.Name == 'Bolt' then
- v.Transparency = 0
- elseif v.Name == 'BoltBack' then
- v.Transparency = 1
- end
- end
- end
- end
- function usefx()
- spawn(function()
- local mode = true
- light.Enabled = mode
- flash.Enabled = mode
- smoke.Enabled = mode
- if not boltaction and not boltaction2 then
- togglebolt('back')
- end
- wait()
- mode = false
- if not boltaction and not boltaction2 then
- togglebolt('normal')
- end
- light.Enabled = mode
- flash.Enabled = mode
- smoke.Enabled = mode
- end)
- end
- function alive(c)
- if c and c:FindFirstChildOfClass("Humanoid") and c:FindFirstChildOfClass("Humanoid").Health > 0 and (c:FindFirstChild("HumanoidRootPart") or c:FindFirstChild("Torso")) and c:FindFirstChild("Head") then
- return true
- end
- return false
- end
- function exists(c)
- if c and c:FindFirstChildOfClass("Humanoid") and (c:FindFirstChild("HumanoidRootPart") or c:FindFirstChild("Torso")) and c:FindFirstChild("Head") then
- return true
- end
- return false
- end
- function reload()
- if max_ammo > ammo then else return end
- if 0 >= tot_ammo then
- remote:FireServer({
- tool = tool,
- },'empty')
- return
- end
- aim_type = 0
- aim()
- can_scope = false
- using = true
- reloading = true
- remote:FireServer({
- tool = tool,
- },'reload')
- if boltaction or boltaction2 then
- togglebolt('back')
- spawn(function()
- wait(0.2)
- drop_shell()
- end)
- end
- if not boltaction then
- local m = mag:Clone()
- m.CanCollide = true
- pcall(function()
- m:FindFirstChild("Weld"):Destroy()
- end)
- m.Parent = junk
- game:GetService("Debris"):AddItem(m,10)
- end
- mag.Transparency = 1
- wait(reload_s.TimeLength)
- if max_ammo >= tot_ammo then
- ammo = ammo + tot_ammo
- tot_ammo = 0
- if ammo > max_ammo then
- local reserve = ammo-max_ammo
- ammo = ammo - reserve
- tot_ammo = tot_ammo + reserve
- end
- elseif tot_ammo > max_ammo then
- ammo = ammo + max_ammo
- tot_ammo = tot_ammo - max_ammo
- if ammo > max_ammo then
- local reserve = ammo-max_ammo
- ammo = ammo - reserve
- tot_ammo = tot_ammo + reserve
- end
- end
- script:FindFirstChild('ammo').Value = ammo
- script:FindFirstChild('total_ammo').Value = tot_ammo
- if equipped then
- if hud then
- hud.ammo.Text = ammo .. '/' .. tot_ammo
- end
- end
- if boltaction2 then
- togglebolt('normal')
- end
- if not boltaction then
- mag.Transparency = 0
- end
- reloading = false
- using = false
- can_scope = true
- end
- function drop_shell()
- local Shell = Instance.new("Part")
- Shell.Color = Color3.new(1, 1, 0)
- Shell.BottomSurface = Enum.SurfaceType.Smooth
- Shell.BrickColor = BrickColor.new("New Yeller")
- Shell.Material = Enum.Material.Metal
- Shell.Shape = Enum.PartType.Cylinder
- Shell.CFrame = chamber_part.CFrame
- local bt = bullettypes[bullettype]
- local mesh = Instance.new("SpecialMesh")
- mesh.MeshId = bt.mesh
- mesh.TextureId = bt.texture
- mesh.Scale = bt.scale
- mesh.Parent = Shell
- Shell.Size = bt.size
- Shell.Parent = junk
- local bvs = Instance.new("BodyVelocity")
- bvs.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- bvs.Velocity = ((chamber_part.CFrame.lookVector*1)+Vector3.new(0,2,0))*5
- bvs.Parent = Shell
- game:GetService("Debris"):AddItem(bvs,0.1)
- game:GetService("Debris"):AddItem(Shell,10)
- end
- function raycast(Pos, Dir, Max, Ignore)
- local rayparams = RaycastParams.new()
- rayparams.FilterType = Enum.RaycastFilterType.Blacklist
- rayparams.FilterDescendantsInstances = Ignore
- rayparams.IgnoreWater = true
- return workspace:Raycast(Pos, Dir * (Max or 999.999), rayparams)
- end
- function break_window(hit)
- if hit.Material == Enum.Material.Glass and hit.Name ~= 'window shatter' and hit.Name ~= 'blood' and hit.Name ~= 'blood_drop' then else return end
- hit.Name = ''
- remote:FireServer({
- tool = tool,
- },'break')
- local sx,sy,sz = hit.Size.x,hit.Size.y,hit.Size.z
- for x = 1,4 do
- for y = 1,4 do
- local part = hit:Clone()
- local position = Vector3.new(x-2.1,y-2.1,0)*Vector3.new(sx/4,sy/4,sz)
- part.Size = Vector3.new(sx/4,sy/4,sz)
- part.CFrame = hit.CFrame*(CFrame.new(part.Size/8)-hit.Size/8+position)
- part.Velocity = Vector3.new(math.random(-10,10),math.random(-10,10),math.random(-10,10))
- part.Name = "window shatter"
- part.Parent = hit.Parent
- game:GetService("Debris"):AddItem(part,2)
- spawn(function()
- wait(0.5)
- for i = 1,10 do
- part.Transparency = part.Transparency+0.05
- wait(0.05)
- end
- part:Destroy()
- end)
- part.Anchored = false
- end
- end
- hit:Destroy()
- end
- function make_hole(pos,obj,col)
- local BulletHolePart = Instance.new("Part")
- BulletHolePart.Massless = true
- BulletHolePart.Anchored = false
- BulletHolePart.CanCollide = false
- BulletHolePart.Locked = true
- BulletHolePart.FormFactor = "Custom"
- BulletHolePart.TopSurface, BulletHolePart.BottomSurface, BulletHolePart.RightSurface, BulletHolePart.LeftSurface, BulletHolePart.FrontSurface, BulletHolePart.BackSurface = "SmoothNoOutlines", "SmoothNoOutlines", "SmoothNoOutlines", "SmoothNoOutlines", "SmoothNoOutlines", "SmoothNoOutlines"
- BulletHolePart.Name = "Bullet Hole"
- BulletHolePart.Material = "Plastic"
- BulletHolePart.Reflectance = 0
- BulletHolePart.Transparency = 1
- BulletHolePart.BrickColor = BrickColor.new("Medium stone grey")
- BulletHolePart.Size = Vector3.new(0.3, 0, 0.3)
- BulletHolePart:BreakJoints()
- BulletHolePart.CFrame = pos
- BulletHolePart.Parent = junk
- local weld = Instance.new("WeldConstraint")
- weld.Part0 = obj
- weld.Part1 = BulletHolePart
- weld.Parent = obj
- game:GetService("Debris"):AddItem(BulletHolePart, 5)
- local BulletHoleDecal = Instance.new("Decal")
- BulletHoleDecal.Color3 = Color3.new(col.r, col.g, col.b)
- BulletHoleDecal.Face = "Top"
- BulletHoleDecal.Texture = "rbxassetid://359667865"
- BulletHoleDecal.Transparency = 0
- BulletHoleDecal.Parent = BulletHolePart
- return BulletHolePart
- end
- function fire(dir,t,ignore)
- local p1 = head.Position
- local p2 = (dir-p1).Unit
- local result = raycast(p1, p2, 1000, ignore)
- remote:FireServer({
- hitpos = mouse.Hit.p,
- tool = tool,
- },'shoot')
- if result then
- local hitrot = result.Normal
- local hitpos = result.Position
- local obj = result.Instance
- local targplr,targchar,targhum,targtorso,targhead
- targchar = obj.Parent
- targplr = game:GetService("Players"):GetPlayerFromCharacter(targchar)
- for i,v in pairs(game:GetService("Players"):GetPlayers()) do
- if v.Character and obj:IsDescendantOf(v.Character) then
- targchar = v.Character
- break
- end
- end
- targhum = targchar:FindFirstChildOfClass("Humanoid")
- targtorso = targchar:FindFirstChild("Torso") or targchar:FindFirstChild("UpperTorso") or targchar:FindFirstChild("HumanoidRootPart")
- targhead = targchar:FindFirstChild("Head")
- if exists(targchar) and targchar ~= char then
- if not obj:FindFirstChild('Dismembered') then
- local dmg = 0
- if obj.Name == 'Head' then
- dmg = math.random(15,17)
- elseif obj == targtorso or obj == targchar:FindFirstChild("HumanoidRootPart") then
- dmg = math.random(12,14)
- else
- dmg = math.random(7,11)
- end
- remote:FireServer({
- targhum = targhum,
- targchar = targchar,
- targtorso = targtorso,
- targplr = targplr,
- targhead = targhead,
- obj = obj,
- dmg = dmg,
- p1 = p1,
- p2 = p2,
- hitpos = hitpos,
- tool = tool,
- },'dmg')
- end
- else
- local soundfont=({
- Brick="stonehit";
- Cobblestone="stonehit";
- Concrete="stonehit";
- CorrodedMetal="metalhit";
- DiamondPlate="metalhit";
- Fabric=nil;
- Foil="metalhit";
- Granite="stonehit";
- Grass="grasshit";
- Ice="stonehit";
- Marble="stonehit";
- Metal="metalhit";
- Neon=nil;
- Pebble="stonehit";
- Plastic="metalhit";
- Sand=nil;
- Slate="stonehit";
- SmoothPlastic="metalhit";
- Wood="woodhit";
- WoodPlanks="woodhit";
- })[obj.Material.Name]
- local bhole = make_hole(CFrame.new(hitpos, hitpos - hitrot) * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)) * CFrame.Angles(math.rad(0), math.rad(math.random(-360, 360)), math.rad(0)), obj, obj.BrickColor)
- local BulletHoleSound = Instance.new("Sound")
- BulletHoleSound.Volume = 0.5
- BulletHoleSound.Pitch = math.random(9,11)/10
- if soundfont ~= nil then
- BulletHoleSound.SoundId = "rbxassetid://"..libruary[soundfont][math.random(1,6)]
- else
- BulletHoleSound.SoundId = "rbxassetid://"..libruary['impact'][1]
- end
- BulletHoleSound.Parent = bhole
- BulletHoleSound:Play()
- break_window(obj)
- end
- local nt = ignore
- table.insert(nt,1,obj)
- if 3 >= t then
- fire(hitpos,t+1,nt)
- end
- end
- end
- function shoot()
- aim_type = 0
- aim()
- using = true
- can_scope = false
- for i = 1,bulletfire do
- local mousepos = mouse.Hit.p
- if 0 >= ammo then
- using = false
- reload()
- return
- end
- lastshot = tick()
- game:GetService("TweenService"):Create(tool,TweenInfo.new(0.2),{
- Grip = grips.shooting
- }):Play()
- if not op then
- ammo = ammo - 1
- end
- if hud then
- hud.ammo.Text = ammo .. '/' .. tot_ammo
- end
- usefx()
- if not boltaction and not boltaction2 then
- drop_shell()
- end
- cam_recoil()
- --
- local ignore = {char,junk}
- for _,p in ipairs(game:GetService("Players"):GetPlayers()) do
- if p.Character then
- for i,v in ipairs(p.Character:GetChildren()) do
- if v:IsA("Accessory") or v:IsA("Tool") then
- table.insert(ignore,1,v)
- end
- end
- end
- end
- fire(mousepos,1,ignore)
- --
- if not op then
- wait(shootwait)
- else
- wait(0)
- end
- game:GetService("TweenService"):Create(tool,TweenInfo.new(0.2),{
- Grip = grips.equipped
- }):Play()
- end
- if boltaction2 and ammo > 0 then
- togglebolt('back')
- spawn(function()
- wait(0.2)
- drop_shell()
- end)
- end
- if not op and needcool then
- wait(boltwait*bulletfire)
- end
- if boltaction2 and ammo > 0 then
- togglebolt('normal')
- end
- can_scope = true
- using = false
- end
- tool.Equipped:Connect(function()
- equipped = true
- remote:FireServer({
- tool = tool,
- },'equip')
- ammo = script:FindFirstChild('ammo').Value
- tot_ammo = script:FindFirstChild('total_ammo').Value
- if not alive(char) then return end
- if hud then
- hud.ammo.Visible = true
- hud.ammo.Text = ammo .. '/' .. tot_ammo
- end
- end)
- tool.Unequipped:Connect(function()
- equipped = false
- aim_type = 0
- aim()
- equip:Stop()
- script:FindFirstChild('ammo').Value = ammo
- script:FindFirstChild('total_ammo').Value = tot_ammo
- if hud then
- hud.ammo.Visible = false
- hud.ammo.Text = '0/0'
- end
- end)
- hum.Died:Connect(function()
- aim_type = 0
- aim()
- script:FindFirstChild('ammo').Value = ammo
- script:FindFirstChild('total_ammo').Value = tot_ammo
- if hud then
- hud.ammo.Visible = false
- hud.ammo.Text = '0/0'
- end
- tool:Destroy()
- end)
- function cam_recoil()
- spawn(function()
- local r = 1000/recoil_power
- local r2 = r/3
- local x = (math.random(r/10,r)/r2)/(r/4) -- real y
- local y = (math.random(-r,r)/r2)/(r/3) -- fake y
- local z = (math.random(-r,r)/r2)/(r/4)
- local t = 0.1
- local m = 60
- for i = t*m,1,-1 do
- local ct = m/m/i
- camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(x*ct,y*ct,z*ct)
- game:GetService("RunService").RenderStepped:Wait()
- end
- end)
- end
- function aim()
- if can_scope and has_scope then
- local pgui = plr:FindFirstChildOfClass("PlayerGui")
- local aim_ui = pgui:FindFirstChild('scope')
- local dof = game:GetService("Lighting"):FindFirstChild("DepthOfField")
- remote:FireServer({
- tool = tool,
- },'aim')
- if aim_type == 0 then
- --hum.WalkSpeed = 16
- if aim_ui then
- aim_ui:Destroy()
- end
- game:GetService("TweenService"):Create(dof,TweenInfo.new(0.25),{InFocusRadius = 100}):Play()
- game:GetService("UserInputService").MouseDeltaSensitivity = original_sens
- game:GetService("TweenService"):Create(camera,TweenInfo.new(0.25),{FieldOfView = 70}):Play()
- elseif aim_type == 1 then
- --hum.WalkSpeed = 10
- if not aim_ui then
- aim_ui = script.scope:Clone()
- aim_ui.Parent = pgui
- end
- game:GetService("TweenService"):Create(dof,TweenInfo.new(0.25),{InFocusRadius = 140}):Play()
- game:GetService("UserInputService").MouseDeltaSensitivity = original_sens/3
- game:GetService("TweenService"):Create(camera,TweenInfo.new(0.25),{FieldOfView = 20}):Play()
- elseif aim_type == 2 then
- --hum.WalkSpeed = 8
- if not aim_ui then
- aim_ui = script.scope:Clone()
- aim_ui.Parent = pgui
- end
- game:GetService("TweenService"):Create(dof,TweenInfo.new(0.25),{InFocusRadius = 200}):Play()
- game:GetService("UserInputService").MouseDeltaSensitivity = original_sens/5
- game:GetService("TweenService"):Create(camera,TweenInfo.new(0.25),{FieldOfView = 10}):Play()
- end
- end
- end
- function handle_request(mode)
- if alive(char) and not reloading and equipped and not using then
- if mode == 1 then -- shoot
- if firemode == 1 then -- semi
- shoot()
- elseif firemode == 2 then -- auto
- while shooting and equipped do
- shoot()
- wait(shootwait)
- end
- elseif firemode == 3 then -- burst
- shoot()
- end
- elseif mode == 2 then -- reload
- reload()
- end
- end
- end
- uis.InputBegan:Connect(function(input,gamepress)
- if not gamepress and equipped and not reloading and not using and alive(char) then else return end
- local mode = 0
- if input.UserInputType == Enum.UserInputType.Keyboard then
- local key = input.KeyCode
- if key == Enum.KeyCode.R then
- mode = 2
- elseif key == Enum.KeyCode.V then
- change_firemode()
- end
- elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
- shooting = true
- mode = 1
- elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
- aim_type = aim_type + 1
- if aim_type > 2 then
- aim_type = 0
- end
- aim()
- end
- handle_request(mode)
- end)
- uis.InputEnded:Connect(function(input,gamepress)
- if gamepress then return end
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- shooting = false
- end
- end)
- local crackSmall = {
- 873119768, 873119788, 873119811, 873119845, 873119886, 873119904
- }
- local crackBig = {
- 873119597, 873119653, 873119679, 873119703, 873119724, 873119744
- }
- local whizz = {
- 873121840, 873121858, 873121876, 873121896, 873121913, 873121936
- }
- function suppress(dist)
- local max = 30
- local mid = max/3*2
- local min = max/3
- if max >= dist then
- if min >= dist then
- local sound = Instance.new("Sound",workspace)
- sound.SoundId = 'rbxassetid://' .. crackBig[math.random(1,#crackBig)]
- sound.Volume = min/dist
- sound:Play()
- game:GetService("Debris"):AddItem(sound,5)
- elseif mid >= dist then
- local sound = Instance.new("Sound",workspace)
- sound.SoundId = 'rbxassetid://' .. crackSmall[math.random(1,#crackSmall)]
- sound.Volume = mid/dist
- sound:Play()
- game:GetService("Debris"):AddItem(sound,5)
- elseif max >= dist then
- local sound = Instance.new("Sound",workspace)
- sound.SoundId = 'rbxassetid://' .. whizz[math.random(1,#whizz)]
- sound.Volume = max/dist
- sound:Play()
- game:GetService("Debris"):AddItem(sound,5)
- end
- spawn(function()
- local r = 6000*(math.clamp(dist,0,max)/max)
- local r2 = r/3
- local x = (math.random(-r,r)/r2)/(r/4) -- real y
- local y = (math.random(-r,r)/r2)/(r/3) -- fake y
- local z = (math.random(-r,r)/r2)/(r/4)
- local t = 0.1
- local m = 60
- for i = t*m,1,-1 do
- local ct = m/m/i
- camera.CFrame = camera.CFrame * CFrame.fromEulerAnglesXYZ(x*ct,y*ct,z*ct)
- game:GetService("RunService").RenderStepped:Wait()
- end
- end)
- end
- end
- remote.OnClientEvent:Connect(function(data,mode)
- if mode == 'shoot' then
- local plr = data.plr
- local hitpos = data.hitpos
- local handle = data.handle
- if plr ~= game:GetService("Players").LocalPlayer then
- local campos = camera.CFrame.p
- local dist = (campos-hitpos).Magnitude
- suppress(dist)
- end
- end
- end)
- ]],tool)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement