Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tool = script.Parent;
- debounce = false
- ammotype = script.Parent.Stats.AmmoType.Value
- damage = script.Parent.Stats.Damage.Value
- a = script.Parent.Stats.Accuracy.Value
- b = script.Parent.Stats.Accuracy.Zoomed.Value
- o = script.Parent.Stats.Offset.Value
- action = script.Parent.Stats.Action
- r = script.Parent.Stats.Recoil.Value
- mag = script.Parent.Magazine
- mag1 = mag:findFirstChild("mag1")
- mag2 = mag:findFirstChild("mag2")
- mag3 = mag:findFirstChild("mag3")
- leftdown = false
- activated = false
- local shotsfired = 0
- local player = game.Players.LocalPlayer
- local camera = game.Workspace.CurrentCamera
- local camvector = nil
- local torso = player.Character.Torso
- local r1 = 0
- local r2 = 0
- local rightweld = nil
- local leftweld = nil
- local switching = false
- local firstlock = false
- local recoiled = false
- local rX = 0
- local rY = 0
- local rZ = 0
- local gunmarker = nil
- local arms = nil
- local welds = {}
- local sposl = Vector3.new(0.81, -0.68, -0.03)
- local sanglel = Vector3.new(math.rad(0), math.rad(0), math.rad(-50))
- local sposr = Vector3.new(-1, 0.6, -1.1)
- local sangler = Vector3.new(math.rad(-90), math.rad(-0), math.rad(0))
- local pposl = Vector3.new(1.15, -0.06, -0.03)
- local panglel = Vector3.new(math.rad(0), math.rad(0), math.rad(-50))
- local pposr = Vector3.new(-0.8, 0.05, -1.1)
- local pangler = Vector3.new(math.rad(-90), math.rad(-5), math.rad(0))
- local adsposl = Vector3.new(0.5, -0.6, -0.05)
- local adsanglel = Vector3.new(math.rad(0), math.rad(0), math.rad(-30))
- local adsposr = Vector3.new(0, 0.8, -1.06)
- local adsangler = Vector3.new(math.rad(-90), math.rad(0), math.rad(0))
- if script.Parent:FindFirstChild("primarymarker") then
- gunmarker = script.Parent.primarymarker
- weldposl = pposl
- weldanglel = panglel
- weldposr = pposr
- weldangler = pangler
- elseif script.Parent:FindFirstChild("secondarymarker") then
- gunmarker = script.Parent.secondarymarker
- weldposl = sposl
- weldanglel = sanglel
- weldposr = sposr
- weldangler = sangler
- end
- function FindIgnorance()
- local kingme = {}
- table.insert(kingme, player.Character)
- local totes = game.Workspace.Vehicles:GetChildren()
- for ily = 1, #totes do
- if totes[ily]:FindFirstChild("Windows",true) then
- local yum = totes[ily]:FindFirstChild("Windows",true):GetChildren()
- for my = 1, #yum do
- if yum[my].className == "Part" then
- if yum[my].Transparency == 1 then
- table.insert(kingme,yum[my])
- end
- end
- end
- end
- end
- local button = game.Workspace:GetChildren()
- for pop = 1, #button do
- if button[pop]:FindFirstChild("Shooter",true) then
- table.insert(kingme,button[pop]:FindFirstChild("Shooter",true).Parent)
- end
- if button[pop]:FindFirstChild("Backpack") then
- table.insert(kingme,button[pop]:FindFirstChild("Backpack"))
- end
- end
- return kingme end
- function WeldArms()
- wait()
- arms = {Tool.Parent:FindFirstChild("Left Arm"), Tool.Parent:FindFirstChild("Right Arm")}
- if arms and torso then
- local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
- if sh then
- local yes = true
- if yes then
- yes = false
- sh[1].Part1 = nil
- sh[2].Part1 = nil
- local weld1 = Instance.new("Weld")
- weld1.Part0 = arms[2]
- weld1.Parent = torso
- weld1.Part1 = arms[1]
- weld1.C1 = CFrame.new(weldposl) * CFrame.Angles(weldanglel.x,weldanglel.y,weldanglel.z)
- welds[1] = weld1
- local weld2 = Instance.new("Weld")
- weld2.Part0 = Tool.Parent.Head
- weld2.Parent = torso
- weld2.Part1 = arms[2]
- weld2.C1 = CFrame.new(weldposr) * CFrame.Angles(weldangler.x,weldangler.y,weldangler.z)
- welds[2] = weld2
- end
- end
- end
- end
- function RemoveWelds()
- if arms and torso then
- local sh = {torso:FindFirstChild("Left Shoulder"), torso:FindFirstChild("Right Shoulder")}
- if sh then
- local yes = true
- if yes then
- yes = false
- sh[1].Part1 = arms[1]
- sh[2].Part1 = arms[2]
- welds[1].Parent = nil
- welds[2].Parent = nil
- end
- end
- end
- end
- function Weld(x,y)
- local W = Instance.new("Weld")
- W.Part0 = x
- W.Part1 = y
- local CJ = CFrame.new(x.Position)
- local C0 = x.CFrame:inverse()*CJ
- local C1 = y.CFrame:inverse()*CJ
- W.C0 = C0
- W.C1 = C1
- W.Parent = x
- end
- function Get(A)
- if A.className == "Part" then
- Weld(script.Parent.Handle, A)
- A.Anchored = false
- else
- local C = A:GetChildren()
- for i=1, #C do
- Get(C[i])
- end
- end
- end
- function Finale()
- Get(script.Parent)
- end
- function findWelds()
- local lewelds = player.Character.Torso:GetChildren()
- leftweld = nil
- rightweld = nil
- for i = 1, #lewelds do
- if lewelds[i].className == "Weld" then
- if lewelds[i].Part1 == player.Character:findFirstChild("Left Arm") then
- leftweld = lewelds[i]
- end
- if lewelds[i].Part1 == player.Character:findFirstChild("Right Arm") then
- rightweld = lewelds[i]
- end
- end
- end
- end
- function fire(unit)
- local character = Tool.Parent
- ammo = mag.Value
- if ammo and ammo.Parent and not debounce then
- debounce = true
- if tonumber((string.sub(ammo.Parent.Value,2,2) .. string.sub(ammo.Parent.Value,4))) > 0 then
- player.playerstats.vanitystats.bullets.Value = player.playerstats.vanitystats.bullets.Value + 1
- character.Humanoid.WalkSpeed = 9
- local hit,position = nil
- local ignoreparts = FindIgnorance()
- local lefactor = 1
- local mefactor = 1
- if player.Backpack.GlobalFunctions.crouching.Value then
- lefactor = 0.9
- mefactor = 0.7
- end
- if Tool.Handle.Fire.Pitch < 4 then
- local flash = game.Lighting.Flash:clone()
- flash.Parent = script.Parent.Handle
- end
- if firstlock and not switching then
- local shootray = Ray.new(character.Head.Position, (unit*(600)+Vector3.new(math.random(-b,b),math.random(-b,b),math.random(-b,b))*mefactor))
- hit,position = game.Workspace:FindPartOnRayWithIgnoreList(shootray, ignoreparts)
- else
- local shootray = Ray.new(character.Head.Position, (unit*(600)+Vector3.new(math.random(-a,a),math.random(-a,a),math.random(-a,a))*lefactor))
- hit,position = game.Workspace:FindPartOnRayWithIgnoreList(shootray, ignoreparts)
- end
- local hop,pop = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(character.Head.Position, (unit*600)), ignoreparts)
- if hop then
- local humanoid = hop.Parent:findFirstChild("Humanoid")
- if not humanoid and hop.Parent ~= game.Workspace then
- humanoid = hop.Parent.Parent:findFirstChild("Humanoid")
- end
- if not humanoid and hop.Parent ~= game.Workspace and hop.Parent.Parent ~= game.Workspace then
- humanoid = hop.Parent.Parent.Parent:findFirstChild("Humanoid")
- end
- if humanoid and game.Players:FindFirstChild(humanoid.Parent.Name) then
- if humanoid.Parent.pvptag.Value == 0 then
- player.Character.pvptag.Timer.Value = 30
- player.Character.pvptag.Value = 1
- end
- end
- end
- if hit then
- local newdamage = damage
- if hit.Name == "Left Arm" or hit.Name == "Left Leg" or hit.Name == "Right Arm" or hit.Name == "Right Leg" then
- newdamage = math.ceil(damage*(3/4))
- elseif hit.Name == "Head" or hit.Parent.Name == "NewHead" or hit.Parent:FindFirstChild("thisishair") then
- newdamage = math.floor(damage*(3/2))
- if not hit:IsDescendantOf(game.Workspace.Zombies) then
- player.playerstats.vanitystats.headshots.player.Value = player.playerstats.vanitystats.headshots.player.Value + 1
- end
- end
- if hit.Parent.className ~= "Tool" then
- if hit.Parent.Name == "Animal" then
- hit.Parent.Health.Value = 0
- player.playerstats.vanitystats.animals.Value = player.playerstats.vanitystats.animals.Value + 1
- end
- local humanoid = hit.Parent:findFirstChild("Humanoid")
- if not humanoid and hit.Parent ~= game.Workspace then
- humanoid = hit.Parent.Parent:findFirstChild("Humanoid")
- end
- if not humanoid and hit.Parent ~= game.Workspace and hit.Parent.Parent ~= game.Workspace then
- humanoid = hit.Parent.Parent.Parent:findFirstChild("Humanoid")
- end
- if humanoid then
- player.playerstats.vanitystats.damage.dealt.Value = player.playerstats.vanitystats.damage.dealt.Value + newdamage
- blood = game.Lighting.Blood:clone()
- blood.RemoveScript.Disabled = false
- blood.Parent = hit
- if humanoid.Parent.Name == "Zombie" then
- if humanoid.Health > 0 then
- if humanoid.Health <= newdamage then
- if humanoid.Parent.Role.Value == "Military" then
- player.playerstats.ZombieKill.Military.Value = player.playerstats.ZombieKill.Military.Value + 1
- else
- player.playerstats.ZombieKill.Civilian.Value = player.playerstats.ZombieKill.Civilian.Value + 1
- end
- humanoid.Health = 0
- elseif hit.Name == "Head" or hit.Name == "Handle" or hit.Name == "Helmet" then
- if humanoid.Parent:FindFirstChild("Helmet") then
- local fark = math.random(1,32-damage)
- if fark >= 1 and fark <= 7 then
- player.playerstats.vanitystats.damage.dealt.Value = player.playerstats.vanitystats.damage.dealt.Value + (humanoid.Health - newdamage)
- player.playerstats.ZombieKill.Military.Value = player.playerstats.ZombieKill.Military.Value + 1
- player.playerstats.vanitystats.headshots.zombie.Value = player.playerstats.vanitystats.headshots.zombie.Value + 1
- humanoid.Health = 0
- else
- blood.Parent = nil
- humanoid.Parent:FindFirstChild("Helmet").Handle.Ping:Play()
- end
- else
- if humanoid.Parent.Role.Value == "Military" then
- player.playerstats.ZombieKill.Military.Value = player.playerstats.ZombieKill.Military.Value + 1
- else
- player.playerstats.ZombieKill.Civilian.Value = player.playerstats.ZombieKill.Civilian.Value + 1
- end
- player.playerstats.vanitystats.damage.dealt.Value = player.playerstats.vanitystats.damage.dealt.Value + (humanoid.Health - newdamage)
- player.playerstats.vanitystats.headshots.zombie.Value = player.playerstats.vanitystats.headshots.zombie.Value + 1
- humanoid.Health = 0
- end
- else
- humanoid.Health = humanoid.Health - newdamage
- end
- end
- end
- if humanoid.Parent.Name ~= "Zombie" then
- if humanoid:FindFirstChild("Regeneration") then
- if humanoid.Health <= newdamage and humanoid.Health > 0 then
- local targetcharacter = humanoid.Parent
- local prey = game.Players:GetPlayerFromCharacter(targetcharacter)
- if prey.playerstats.PlayerKill.Aggressive.Value < 3 then
- if targetcharacter.pvptag.Value == 0 then
- player.playerstats.PlayerKill.Aggressive.Value = player.playerstats.PlayerKill.Aggressive.Value + 1
- elseif targetcharacter.pvptag.Value == 1 then
- player.playerstats.PlayerKill.Defensive.Value = player.playerstats.PlayerKill.Defensive.Value + 1
- end
- elseif prey.playerstats.PlayerKill.Aggressive.Value >= 3 then
- player.playerstats.PlayerKill.Bandit.Value = player.playerstats.PlayerKill.Bandit.Value + 1
- end
- end
- lecheck = true
- local playergroup = game.Lighting.Groups:findFirstChild(game.Players.LocalPlayer:findFirstChild("MyGroup", true).groupid.Value)
- if playergroup then
- local gasp = playergroup:GetChildren()
- for ha = 1, #gasp do
- if gasp[ha].Value == humanoid.Parent.Name then
- lecheck = false
- end
- end
- end
- if lecheck then
- humanoid.Regeneration.Value = true
- humanoid.Health = humanoid.Health - newdamage
- end
- else
- humanoid.Health = humanoid.Health - newdamage
- end
- end
- else
- if hit.Transparency == 0 then
- local bullet = game.Lighting.Bullet:clone()
- bullet.Position = position
- if hit:IsDescendantOf(game.Workspace:FindFirstChild("Anchored Objects"):FindFirstChild("Plates")) or hit:IsDescendantOf(game.Workspace:FindFirstChild("Anchored Objects"):FindFirstChild("Trees/Foliage")) then
- if game.Lighting:GetMinutesAfterMidnight() > 330 and game.Lighting:GetMinutesAfterMidnight() < 1080 then
- bullet.Fire.Color = Color3.new(80/255,60/255,20/255)
- else
- bullet.Fire.Color = Color3.new(30/255,20/255,10/255)
- end
- bullet.Fire.Heat = 9
- end
- bullet.Parent = game.Workspace
- end
- end
- if hit.Parent ~= game.Workspace then
- if hit.Parent.Parent ~= game.Workspace then
- if hit.Parent.Parent.Parent.Name == "VehicleBody" or hit.Parent.Parent.Name == "VehicleBody" or hit.Parent.Name == "VehicleBody" then
- if hit.Parent.Parent.Parent.Name == "VehicleBody" then
- vehicle = hit.Parent.Parent.Parent
- end
- if hit.Parent.Parent.Name == "VehicleBody" then
- vehicle = hit.Parent.Parent
- end
- if hit.Parent.Name == "VehicleBody" then
- vehicle = hit.Parent
- end
- vehiclestats = vehicle.Parent.Stats
- if hit.Name == "Collider" then
- hullratio = vehiclestats.Hull.Value
- vehiclestats.Hull.Value = vehiclestats.Hull.Value - math.floor(damage/2)*(hullratio/vehiclestats.Hull.MaxHull.Value)
- vehiclestats.Engine.Value = vehiclestats.Engine.Value - math.floor(damage/2)*(1-(hullratio/vehiclestats.Hull.MaxHull.Value))
- elseif hit.Name == "RearCollider" then
- hullratio = vehiclestats.Hull.Value
- vehiclestats.Hull.Value = vehiclestats.Hull.Value - math.floor(damage/2)*(hullratio/vehiclestats.Hull.MaxHull.Value)
- vehiclestats.Tank.Value = vehiclestats.Tank.Value - math.floor(damage/2)*(1-(hullratio/vehiclestats.Hull.MaxHull.Value))
- elseif hit.Name == "Wheel" then
- thewheel = hit.Parent
- rugula = math.random(1,5)
- if rugula == 1 then
- hundr = hit.Parent:GetChildren()
- for hurgle = 1, #hundr do
- hundr[hurgle].Transparency = 1
- hundr[hurgle].CanCollide = false
- end
- end
- else
- vehiclestats.Hull.Value = vehiclestats.Hull.Value - math.floor(damage/2)
- end
- end
- end
- end
- if hit then
- if hit.Name == "Window" then
- local breaksound = game.Lighting.BreakSound:clone()
- breaksound.Broken.Value = hit
- breaksound.Parent = hit
- elseif hit.Parent.Name == "Window" then
- local breaksound = game.Lighting.BreakSound:clone()
- breaksound.Broken.Value = hit.Parent
- breaksound.Parent = hit
- elseif hit.Parent.Name == "Windows" then
- if math.random(1,2) == 1 then
- hit.Transparency = 1
- local breaksound = game.Lighting.BreakSound:clone()
- breaksound.Broken.Value = nil
- breaksound.Parent = hit
- end
- elseif hit.Parent.Name == "PatientZero" then
- player.Character.Humanoid.Health = math.ceil(player.Character.Humanoid.Health*0.81)
- hit.Parent.ShotAt.Value = true
- end
- end
- end
- end
- if firstlock then
- findWelds()
- if leftweld and rightweld then
- addX = (math.random(-2,2)/200)*r/12
- addZ = (math.random(-2,2)/200)*r/12
- addY = 0.025*r/12
- camera.Focus = camera.Focus + Vector3.new(addX, addY, addZ)
- rX = rX + addX
- rZ = rZ + addZ
- rY = rY + addY
- end
- end
- Tool.Handle.Fire:Play()
- player.Character.Humanoid.Visibility.Shooting.Value = Tool.Handle.Fire.Volume
- local ammoval = tonumber((string.sub(ammo.Parent.Value,2,2) .. string.sub(ammo.Parent.Value,4)))
- ammoval = ammoval - 1
- local rounds = tostring(ammoval)
- if ammoval < 10 then
- ammo.Parent.Value = "G0X" .. string.sub(rounds,1)
- else
- ammo.Parent.Value = "G" .. string.sub(rounds,1,1) .. "X" .. string.sub(rounds,2)
- end
- end
- if tonumber((string.sub(ammo.Parent.Value,2,2) .. string.sub(ammo.Parent.Value,4))) <= 0 then
- script.Parent.Reload.Value = 3
- Tool.Handle.Reload:play()
- onDeactivated(mouse)
- wait(script.Parent.Stats.Reload.Value/10)
- ammo.Parent.Parent.Parent.Value = 0
- ammo.Parent.Parent:Destroy()
- FindMag()
- end
- debounce = false
- end
- end
- function check()
- if not Tool.Enabled or script.Parent.Reload.Value > 0 or player.Backpack.GlobalFunctions.sprinting.Value then
- return false
- else
- return true
- end
- end
- Tool.Enabled = true
- function UpdateAmmo()
- if player.PlayerGui:findFirstChild("AmmoLeft") then
- if player.PlayerGui:findFirstChild("AmmoLeft"):findFirstChild("Shoot") then
- player.PlayerGui:findFirstChild("AmmoLeft"):findFirstChild("Shoot").Value = true
- end
- end
- end
- function onCycle(mouse)
- if not activated then
- activated = true
- local targetPos = mouse.Hit.p
- local dist = (targetPos - player.Character.Head.Position).magnitude
- local lookAt = (targetPos - player.Character.Head.Position).unit
- if check() then
- if action.Value == 0 then
- fire(lookAt)
- UpdateAmmo()
- wait(0.1)
- elseif action.Value == 1 then
- fire(lookAt)
- UpdateAmmo()
- wait(60/action.Rate.Value)
- if leftdown then
- activated = false
- onCycle(mouse)
- end
- elseif action.Value == 2 then
- fire(lookAt)
- UpdateAmmo()
- wait(0.6)
- elseif action.Value == 3 then
- fire(lookAt)
- UpdateAmmo()
- wait(60/action.Rate.Value)
- shotsfired = shotsfired + 1
- if shotsfired < 3 then
- activated = false
- onCycle(mouse)
- else
- shotsfired = 0
- end
- elseif action.Value == 4 then
- fire(lookAt)
- UpdateAmmo()
- wait(0.6)
- end
- player.Character.Humanoid.WalkSpeed = 16
- end
- activated = false
- end
- end
- function onActivated(mouse)
- leftdown = true
- onCycle(mouse)
- end
- function onDeactivated(mouse)
- leftdown = false
- if not game.Players.LocalPlayer.Backpack.GlobalFunctions.sprinting.Value then
- Tool.Parent.Humanoid.WalkSpeed = 16
- end
- end
- function onMove(mouse)
- local targ = mouse.Target
- local infogui = game.Lighting.Info:clone()
- if not firstlock then
- if targ and player:DistanceFromCharacter(mouse.Target.Position) < 50 then
- if targ.Parent:findFirstChild("Humanoid") and targ.Parent.Name ~= "Zombie" then
- local oldgui = player.PlayerGui:findFirstChild("Info")
- if oldgui then oldgui:Destroy() end
- infogui.Frame.Text.Text = targ.Parent.Name
- infogui.Frame.Position = UDim2.new(0, ((mouse.X)-80), 0, ((mouse.Y)-20))
- infogui.Parent = player.PlayerGui
- end
- end
- if targ and player:DistanceFromCharacter(mouse.Target.Position) < 50 then
- if targ.Parent.Parent:findFirstChild("Humanoid") and targ.Parent.Parent.Name ~= "Zombie" then
- local oldgui = player.PlayerGui:findFirstChild("Info")
- if oldgui then oldgui:Destroy() end
- infogui.Frame.Text.Text = targ.Parent.Parent.Name
- infogui.Frame.Position = UDim2.new(0, ((mouse.X)-80), 0, ((mouse.Y)-20))
- infogui.Parent = player.PlayerGui
- end
- end
- end
- if targ and not targ.Parent:findFirstChild("Humanoid") and not targ.Parent.Parent:findFirstChild("Humanoid") then
- local oldgui = player.PlayerGui:findFirstChild("Info")
- if oldgui then oldgui:Destroy() end
- end
- if not targ then
- local oldgui = player.PlayerGui:findFirstChild("Info")
- if oldgui then oldgui:Destroy() end
- end
- end
- function onLooking(mouse)
- if firstlock then
- mouse.Icon = "http://www.roblox.com/asset/?id=32935220"
- else
- mouse.Icon = "http://www.roblox.com/asset/?id=105620056"
- end
- if firstlock and not switching then
- if leftweld and rightweld then
- verticalturn = math.asin((mouse.Hit.p - player.Character.Head.Position).unit.y)
- rightweld.C1 = CFrame.new(rightweld.C1.p) * CFrame.Angles(math.rad(-90) - verticalturn,0,0)
- torso.CFrame = CFrame.new(torso.CFrame.p) * CFrame.Angles(0,math.rad(180) + math.atan2((mouse.Hit.p - torso.Position).unit.x,(mouse.Hit.p - torso.Position).unit.z),0)
- end
- end
- end
- function onLookingCheck(mouse)
- if firstlock then
- mouse.Icon = "http://www.roblox.com/asset/?id=32935220"
- else
- mouse.Icon = "http://www.roblox.com/asset/?id=105620056"
- end
- if firstlock and not switching and rY > 0 then
- if leftweld and rightweld then
- verticalturn = math.asin((mouse.Hit.p - player.Character.Head.Position).unit.y)
- rightweld.C1 = CFrame.new(rightweld.C1.p) * CFrame.Angles(math.rad(-90) - verticalturn,0,0)
- torso.CFrame = CFrame.new(torso.CFrame.p) * CFrame.Angles(0,math.rad(180) + math.atan2((mouse.Hit.p - torso.Position).unit.x,(mouse.Hit.p - torso.Position).unit.z),0)
- end
- end
- end
- function onZoomOut(mouse)
- if not firstlock then
- if player.CameraMode ~= "Classic" then
- player.CameraMode = "Classic"
- end
- end
- end
- function FindMag()
- local decisionclip = nil
- local newclip = nil
- local firstammo = mag.Value
- local slots = player.playerstats.slots:GetChildren()
- burstshot = 3
- if firstammo and firstammo.Parent then
- for z = 1, #slots do
- local newclip = slots[z]:findFirstChild(ammotype, true)
- if newclip then
- local newammoval = tonumber((string.sub(newclip.Parent.Value,2,2) .. string.sub(newclip.Parent.Value,4)))
- local firstammoval = tonumber((string.sub(firstammo.Parent.Value,2,2) .. string.sub(firstammo.Parent.Value,4)))
- if decisionclip then
- local decammoval = tonumber((string.sub(decisionclip.Parent.Value,2,2) .. string.sub(decisionclip.Parent.Value,4)))
- if newammoval > firstammoval and newammoval > decammoval then
- decisionclip = newclip
- end
- end
- if not decisionclip then
- if newammoval > firstammoval then
- decisionclip = newclip
- end
- end
- end
- end
- else
- for z = 1, #slots do
- local newclip = slots[z]:findFirstChild(ammotype, true)
- if newclip then
- local newammoval = tonumber((string.sub(newclip.Parent.Value,2,2) .. string.sub(newclip.Parent.Value,4)))
- if decisionclip then
- local decammoval = tonumber((string.sub(decisionclip.Parent.Value,2,2) .. string.sub(decisionclip.Parent.Value,4)))
- if newammoval > decammoval then
- decisionclip = newclip
- end
- end
- if not decisionclip then
- if newammoval then
- decisionclip = newclip
- end
- end
- end
- end
- end
- if decisionclip then
- mag.Value = decisionclip
- end
- local allmags = script.Parent:GetChildren()
- for ka = 1, #allmags do
- if allmags[ka].className == "Part" and string.sub(allmags[ka].Name,1,3):lower() == "mag" then
- allmags[ka].Transparency = 1
- end
- end
- if not mag.Value or not mag.Value.Parent then
- return
- else
- if mag1 then
- if mag.Value.Parent.Parent.Value == mag1.Value then
- for lo = 1, #allmags do
- if allmags[lo].className == "Part" and allmags[lo].Name:lower() == "mag1" then
- allmags[lo].Transparency = 0
- end
- end
- end
- end
- if mag2 then
- if mag.Value.Parent.Parent.Value == mag2.Value then
- for lo = 1, #allmags do
- if allmags[lo].className == "Part" and allmags[lo].Name:lower() == "mag2" then
- allmags[lo].Transparency = 0
- end
- end
- end
- end
- if mag3 then
- if mag.Value.Parent.Parent.Value == mag3.Value then
- for lo = 1, #allmags do
- if allmags[lo].className == "Part" and allmags[lo].Name:lower() == "mag3" then
- allmags[lo].Transparency = 0
- end
- end
- end
- end
- end
- end
- function onKeyDown(key)
- local character = Tool.Parent
- local decisionclip = nil
- local firstammo = nil
- local newclip = nil
- if (key == "r") and script.Parent.Reload.Value == 0 then
- Tool.Handle.Reload:play()
- script.Parent.Reload.Value = 3
- wait(script.Parent.Stats.Reload.Value/10)
- FindMag()
- if game.Players.LocalPlayer.PlayerGui:findFirstChild("AmmoLeft") then
- game.Players.LocalPlayer.PlayerGui.AmmoLeft.Shoot.Value = true
- end
- end
- if key == "f" and not leftdown then
- if action.Original.Value == 1 then
- if action.Value == 0 then
- action.Value = 1
- else
- action.Value = 0
- end
- end
- if action.Original.Value == 3 then
- if action.Value == 0 then
- if not player.PlayerGui.Inventory.toggles.burstfire.Value then
- action.Value = 3
- else
- action.Value = 1
- end
- elseif action.Value == 3 then
- action.Value = 1
- else
- action.Value = 0
- end
- end
- end
- if key == "l" then
- if script.Parent:FindFirstChild("FlashLight",true) then
- if script.Parent:FindFirstChild("FlashLight",true).Enabled then
- script.Parent:FindFirstChild("FlashLight",true).Enabled = false
- else
- script.Parent:FindFirstChild("FlashLight",true).Enabled = true
- end
- end
- end
- if key == "o" and not firstlock then
- player.CameraMode = "Classic"
- end
- if key == player.PlayerGui.Inventory.toggles.aim.Value then
- local wparts = script.Parent:GetChildren()
- for i = 1, #wparts do
- if wparts[i]:FindFirstChild("lenspart") then
- o = (player.Character.Head.Position.Y - wparts[i].Position.Y - 0.04)
- if o > 1 then o = script.Parent.Stats.Offset.Value end
- end
- end
- local mouse = player:GetMouse()
- if not firstlock and not switching and player.Character:findFirstChild("Shooter", true) and camera.FieldOfView > 69 and camera.FieldOfView < 71 and not player.Character.Humanoid.Sit then
- switching = true
- camvector = (camera.CoordinateFrame.p - player.Character.Head.Position)
- camera.CameraType = "Track"
- ting = 0
- rightweld = nil
- leftweld = nil
- firstlock = true
- mouse.Icon = "http://www.roblox.com/asset/?id=32935220"
- findWelds()
- repeat
- if camvector.magnitude > 2 then
- camera.CoordinateFrame = camera.CoordinateFrame - camvector/6
- end
- if leftweld and rightweld then
- rightweld.C1 = rightweld.C1 * CFrame.Angles((adsangler.x - weldangler.x)/5,(adsangler.y - weldangler.y)/5,(adsangler.z - weldangler.z)/5) + (adsposr - weldposr)/5 + Vector3.new(0,0,o/5)
- leftweld.C1 = leftweld.C1 * CFrame.Angles((adsanglel.x - weldanglel.x)/5,(adsanglel.y - weldanglel.y)/5,(adsanglel.z - weldanglel.z)/5) + (adsposl - weldposl)/5
- end
- camera.FieldOfView = camera.FieldOfView - (5 + gunmarker.Value)
- ting = ting + 1
- wait(1/30)
- until ting == 5
- player.CameraMode = "LockFirstPerson"
- if camvector.magnitude > 2 then
- camera.CoordinateFrame = player.Character.Head.CFrame - player.Character.Head.CFrame.lookVector
- end
- camera.CameraType = "Custom"
- switching = false
- if camvector.magnitude < 2 then
- onLooking(mouse)
- end
- player.Character.Humanoid.WalkSpeed = 8
- local emma = player.Character.Head:GetChildren()
- for z = 1, #emma do
- if emma[z].className == "Sound" then
- if emma[z].SoundId == "rbxasset://sounds/bfsl-minifigfoots1.mp3" then
- emma[z].Pitch = 0.9
- end
- end
- end
- return end
- if firstlock and not switching then
- switching = true
- ting = 0
- camera.CameraType = "Track"
- if camvector.magnitude > 2 then
- player.CameraMode = "Classic"
- end
- rightweld = nil
- leftweld = nil
- findWelds()
- if leftweld and rightweld then
- rightweld.C1 = CFrame.new(adsposr) * CFrame.Angles(adsangler.x,adsangler.y,adsangler.z) + Vector3.new(0,0,o)
- leftweld.C1 = CFrame.new(adsposl) * CFrame.Angles(adsanglel.x,adsanglel.y,adsanglel.z)
- end
- firstlock = false
- repeat
- if camvector.magnitude > 2 then
- camera.CoordinateFrame = camera.CoordinateFrame - player.Character.Head.CFrame.lookVector*2 + Vector3.new(0,0.6,0)
- end
- if leftweld and rightweld then
- rightweld.C1 = rightweld.C1 * CFrame.Angles((weldangler.x - adsangler.x)/5,(weldangler.y - adsangler.y)/5,(weldangler.z - adsangler.z)/5) + (weldposr - adsposr)/5 - Vector3.new(0,0,o/5)
- leftweld.C1 = leftweld.C1 * CFrame.Angles((weldanglel.x - adsanglel.x)/5,(weldanglel.y - adsanglel.y)/5,(weldanglel.z - adsanglel.z)/5) + (weldposl - adsposl)/5
- end
- camera.FieldOfView = camera.FieldOfView + (5 + gunmarker.Value)
- ting = ting + 1
- wait()
- until ting == 5
- camera.CameraType = "Custom"
- switching = false
- mouse.Icon = "http://www.roblox.com/asset/?id=105620056"
- player.Character.Humanoid.WalkSpeed = 16
- local emma = player.Character.Head:GetChildren()
- for z = 1, #emma do
- if emma[z].className == "Sound" then
- if emma[z].SoundId == "rbxasset://sounds/bfsl-minifigfoots1.mp3" then
- emma[z].Pitch = 1
- end
- end
- end
- return end
- end
- end
- function onMouseButton2Down(mouse)
- r1 = game.Workspace.DistributedgameTime
- local wparts = script.Parent:GetChildren()
- for i = 1, #wparts do
- if wparts[i]:FindFirstChild("lenspart") then
- o = (player.Character.Head.Position.Y - wparts[i].Position.Y - 0.04)
- if o > 1 then o = script.Parent.Stats.Offset.Value end
- end
- end
- end
- function onMouseButton2Up(mouse)
- r2 = game.Workspace.DistributedgameTime
- if (r2 - r1) < 0.2 and not player.Backpack.GlobalFunctions.sprinting.Value and player.PlayerGui.Inventory.toggles.aim.Value == "Right Mouse" and not player.Character.Humanoid.Sit then
- if not firstlock and not switching and player.Character:findFirstChild("Shooter", true) and camera.FieldOfView > 69 and camera.FieldOfView < 71 then
- switching = true
- camvector = (camera.CoordinateFrame.p - player.Character.Head.Position)
- camera.CameraType = "Track"
- ting = 0
- rightweld = nil
- leftweld = nil
- firstlock = true
- mouse.Icon = "http://www.roblox.com/asset/?id=32935220"
- findWelds()
- repeat
- if camvector.magnitude > 2 then
- camera.CoordinateFrame = camera.CoordinateFrame - camvector/6
- end
- if leftweld and rightweld then
- rightweld.C1 = rightweld.C1 * CFrame.Angles((adsangler.x - weldangler.x)/5,(adsangler.y - weldangler.y)/5,(adsangler.z - weldangler.z)/5) + (adsposr - weldposr)/5 + Vector3.new(0,0,o/5)
- leftweld.C1 = leftweld.C1 * CFrame.Angles((adsanglel.x - weldanglel.x)/5,(adsanglel.y - weldanglel.y)/5,(adsanglel.z - weldanglel.z)/5) + (adsposl - weldposl)/5
- end
- camera.FieldOfView = camera.FieldOfView - (5 + gunmarker.Value)
- ting = ting + 1
- wait(1/30)
- until ting == 5
- player.CameraMode = "LockFirstPerson"
- if camvector.magnitude > 2 then
- camera.CoordinateFrame = player.Character.Head.CFrame - player.Character.Head.CFrame.lookVector
- end
- camera.CameraType = "Custom"
- switching = false
- if camvector.magnitude < 2 then
- onLooking(mouse)
- end
- player.Character.Humanoid.WalkSpeed = 8
- local emma = player.Character.Head:GetChildren()
- for z = 1, #emma do
- if emma[z].className == "Sound" then
- if emma[z].SoundId == "rbxasset://sounds/bfsl-minifigfoots1.mp3" then
- emma[z].Pitch = 0.9
- end
- end
- end
- return end
- if firstlock and not switching then
- switching = true
- ting = 0
- camera.CameraType = "Track"
- if camvector.magnitude > 2 then
- player.CameraMode = "Classic"
- end
- rightweld = nil
- leftweld = nil
- findWelds()
- if leftweld and rightweld then
- rightweld.C1 = CFrame.new(adsposr) * CFrame.Angles(adsangler.x,adsangler.y,adsangler.z) + Vector3.new(0,0,o)
- leftweld.C1 = CFrame.new(adsposl) * CFrame.Angles(adsanglel.x,adsanglel.y,adsanglel.z)
- end
- firstlock = false
- repeat
- if camvector.magnitude > 2 then
- camera.CoordinateFrame = camera.CoordinateFrame - player.Character.Head.CFrame.lookVector*2 + Vector3.new(0,0.6,0)
- end
- if leftweld and rightweld then
- rightweld.C1 = rightweld.C1 * CFrame.Angles((weldangler.x - adsangler.x)/5,(weldangler.y - adsangler.y)/5,(weldangler.z - adsangler.z)/5) + (weldposr - adsposr)/5 - Vector3.new(0,0,o/5)
- leftweld.C1 = leftweld.C1 * CFrame.Angles((weldanglel.x - adsanglel.x)/5,(weldanglel.y - adsanglel.y)/5,(weldanglel.z - adsanglel.z)/5) + (weldposl - adsposl)/5
- end
- camera.FieldOfView = camera.FieldOfView + (5 + gunmarker.Value)
- ting = ting + 1
- wait()
- until ting == 5
- camera.CameraType = "Custom"
- switching = false
- mouse.Icon = "http://www.roblox.com/asset/?id=105620056"
- player.Character.Humanoid.WalkSpeed = 16
- local emma = player.Character.Head:GetChildren()
- for z = 1, #emma do
- if emma[z].className == "Sound" then
- if emma[z].SoundId == "rbxasset://sounds/bfsl-minifigfoots1.mp3" then
- emma[z].Pitch = 1
- end
- end
- end
- return end
- end
- end
- function onEquip(mouse)
- if player.PlayerGui.BicycleHUD.Stats.Visible or player.PlayerGui.VehicleHUD.Stats.Visible or player.PlayerGui.MotorcycleHUD.Stats.Visible or player.Character.Humanoid.Sit then
- player.Character:WaitForChild(script.Parent.Name)
- wait()
- player.Character.Humanoid:UnequipTools()
- return end
- Finale()
- WeldArms()
- local character = Tool.Parent
- local ammoleft = script.Parent.AmmoLeft:clone()
- ammoleft.Frame.LocalScript.Disabled = false
- ammoleft.Parent = player.PlayerGui
- mouse.Button1Down:connect(function() onActivated(mouse) end)
- mouse.Button1Up:connect(function() onDeactivated(mouse) end)
- mouse.Move:connect(function() onMove(mouse) end)
- mouse.Idle:connect(function() onMove(mouse) end)
- mouse.Move:connect(function() onLooking(mouse) end)
- mouse.Idle:connect(function() onLookingCheck(mouse) end)
- mouse.KeyDown:connect(onKeyDown)
- mouse.Icon = "http://www.roblox.com/asset/?id=105620056"
- mouse.Button2Down:connect(function () onMouseButton2Down(mouse) end)
- mouse.Button2Up:connect(function () onMouseButton2Up(mouse) end)
- mouse.WheelBackward:connect(function () onZoomOut(mouse) end)
- if not mag.Value or not mag.Value.Parent then
- FindMag()
- end
- end
- function onUnequip()
- Finale()
- RemoveWelds()
- r1 = 0
- r2 = 0
- rightweld = nil
- leftweld = nil
- switching = false
- firstlock = false
- leftdown = false
- if player.Backpack.GlobalFunctions.sprinting.Value then
- player.Character.Humanoid.WalkSpeed = 23
- camera.FieldOfView = 75
- else
- player.Character.Humanoid.WalkSpeed = 16
- camera.FieldOfView = 70
- end
- if script.Parent:FindFirstChild("FlashLight",true) then
- script.Parent:FindFirstChild("FlashLight",true).Enabled = false
- end
- local emma = player.Character.Head:GetChildren()
- for z = 1, #emma do
- if emma[z].className == "Sound" then
- if emma[z].SoundId == "rbxasset://sounds/bfsl-minifigfoots1.mp3" then
- emma[z].Pitch = 1
- end
- end
- end
- local gcharacter = Tool.Parent.Parent
- local g = gcharacter.PlayerGui:GetChildren()
- for i = 1, #g do
- if g[i].Name == "AmmoLeft" then
- g[i]:Destroy()
- end
- end
- end
- function onMagChanged()
- wait()
- if not mag.Value or not mag.Value.Parent then
- FindMag()
- if game.Players.LocalPlayer.PlayerGui:findFirstChild("AmmoLeft") then
- game.Players.LocalPlayer.PlayerGui.AmmoLeft.Shoot.Value = true
- end
- end
- end
- function onGunChanged()
- wait()
- if script.Parent:FindFirstChild("primarymarker") then
- if player.playerstats.slots.slotprimary.Value == 0 then
- script.Parent:Destroy()
- end
- elseif script.Parent:FindFirstChild("secondarymarker") then
- if player.playerstats.slots.slotsecondary.Value == 0 then
- script.Parent:Destroy()
- end
- end
- end
- script.Parent.Equipped:connect(onEquip)
- script.Parent.Unequipped:connect(onUnequip)
- player.playerstats.slots.DescendantRemoving:connect(onMagChanged)
- Finale()
- if script.Parent:FindFirstChild("primarymarker") then
- player.playerstats.slots.slotprimary.Changed:connect(onGunChanged)
- end
- if script.Parent:FindFirstChild("secondarymarker") then
- player.playerstats.slots.slotsecondary.Changed:connect(onGunChanged)
- end
- while true do
- if firstlock and not switching then
- if player.Character.Humanoid.WalkSpeed == 16 then
- player.Character.Humanoid.WalkSpeed = 8
- end
- findWelds()
- if leftweld and rightweld then
- if rX > 0.0025 or rX < -0.0025 then
- camera.Focus = camera.Focus - Vector3.new(rX/4,0,0)
- rX = rX*3/4
- else
- rX = 0
- end
- if rY > 0.00625 then
- camera.Focus = camera.Focus - Vector3.new(0,rY/4,0)
- rY = rY*3/4
- else
- rY = 0
- end
- if rZ > 0.0025 or rZ < -0.0025 then
- camera.Focus = camera.Focus - Vector3.new(0,0,rZ/4)
- rZ = rZ*3/4
- else
- rZ = 0
- end
- end
- end
- wait()
- end
Advertisement
Add Comment
Please, Sign In to add comment