wait()
Tool = script.Parent;
damage = Tool.Damage.Value
Att = Tool.Attachments.Value
ACCURA = script.Parent.ACC
RangeFinder = Tool.EffectiveRange.Value
HIP = (ACCURA.HIP.Value/10)*1.2
HIPCHANCE = ACCURA.HIP.CHANCE.Value/10
BULLSEYEHIP = HIP*0.9
ADS = ACCURA.ADS.Value/100
ADSCHANCE = ACCURA.ADS.CHANCE.Value/1000
BULLSEYEADS = ADS*0.95
FIRED = ACCURA.FIRED.Value/100
MOVING = ACCURA.MOVING.Value/100
JUMPING = ACCURA.JUMPING.Value/100
CROUCHING = (ACCURA.CROUCHING.Value/100)*-1
AttVal1 = Tool.Attachments.Sights.Validity.Value
AttVal2 = Tool.Attachments.Suppressor.Validity.Value
AttVal3 = Tool.Attachments.Underbarrel.Validity.Value
AttVal4 = Tool.Attachments.Stock.Validity.Value
pock = Tool.Attachments.Stock
sight = Tool.Attachments.Sights
supp = Tool.Attachments.Suppressor
underbarrel = Tool.Attachments.Underbarrel
mag1V = Tool.MagType:FindFirstChild("Mag1")
mag2V = Tool.MagType:FindFirstChild("Mag2")
mag3V = Tool.MagType:FindFirstChild("Mag3")
--Modes; 1 for pump, 2 for bolt, 3 for semi, 4 for auto and semi, 5 for auto semi and burst, 6 for auto semi burst and autohit
--Start; 1 for auto ,2 for semi, 3 burst, 4 autohit, 5 pump and 6 bolt
Type = Tool.Modes.Value
CURRENT = Tool.Modes.Start.Value
desc = Tool.VanityStats.Description.Value
name = Tool.VanityStats.GunName.Value
player = game.Players.LocalPlayer
torso = player.Character:FindFirstChild("Torso")
Gungui = Tool.Gunrounds
reload = 2.1
weleds = {}
really = false
potato = false
debounce = false
faiyah = false
cloned = false
local guigun = Gungui
local timer = time()
local fried = false
local triggered = false
local actualhits = 0
local shotsfired = 0
local bloom = 0
local bipbop = game:GetService("UserInputService")
local ow = Tool.autohit
local mod = 1
local guigun = nil
local anim1 = nil
local anim2 = nil
local anim3 = nil
local equipe = Instance.new("Animation")
equipe.AnimationId = "https://www.roblox.com/item.aspx?id=440116335"
local prefire = Instance.new("Animation")
prefire.AnimationId = "https://www.roblox.com/item.aspx?id=440217580"
local firing = Instance.new("Animation")
firing.AnimationId = "https://www.roblox.com/item.aspx?id=440224699"
local CurrentClip = 20
local Clip = 20
local Totalclip = 400
local player = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera
local mouse = player:GetMouse()
local body = player.Character.Torso
local sniping = false
local bulh = 0
local bulads = 0
local ignore = game.Players.LocalPlayer.Character
local hip = nil
local ads = nil
local hips = nil
local adss = nil
--[[
local PPOSR = Vector3.new(-0.7,0.1,-1.1)
local PANGR = Vector3.new(math.rad(-75),math.rad(-60),math.rad(0))
local PPOSL = Vector3.new(1.95,0.7,-0.2)
local PANGL = Vector3.new(math.rad(20),math.rad(20),math.rad(-50))
local FPPOSR = Vector3.new(-0.7,0.1,-1.1)
local FPANGR = Vector3.new(math.rad(-90),math.rad(-10),math.rad(0))
local FPPOSL = Vector3.new(1.95,0.7,-0.2)
local FPANGL = Vector3.new(math.rad(20),math.rad(-20),math.rad(-50))
local FPPOSH = Vector3.new(0,-1.5,0)
local FPANGH = Vector3.new(math.rad(0),math.rad(40),math.rad(0))
]]--
local ADSPOSR = Vector3.new(-1.3,0,0)
local ADSANGR = Vector3.new(math.rad(-90),math.rad(0),math.rad(0))
local ADSPOSL = Vector3.new(1,0,-1)
local ADSANGL = Vector3.new(math.rad(-90),math.rad(0),math.rad(-30))
if Type == 4 then
mod = 2
elseif Type == 5 then
mod = 3
elseif Type == 6 then
mod = 4
end
function fire(Unit) --needs buffing for server-sided type
bulh = math.random(0,100)
bulads = math.random(0,100)
local bro = Tool.Parent
local hit,position = nil
local ignore = FindIgnorance()
local Dispersion = 0
if CurrentClip > 0 and not debounce then
debounce = true
if not sniping and bulh >= 100-HIPCHANCE then --bro.Head.Position, **LINE BELOW**
local ray = Ray.new(player.Character.Head.Position,(Unit*(975)+Vector3.new(math.random(-BULLSEYEHIP,BULLSEYEHIP),math.random(-BULLSEYEHIP,BULLSEYEHIP),math.random(-BULLSEYEHIP,BULLSEYEHIP))))
hit, position = game.workspace:FindPartOnRayWithIgnoreList(ray, ignore)
elseif not sniping and bulh < 100-HIPCHANCE then
local ray = Ray.new(player.Character.Head.Position,(Unit*(975)+Vector3.new(math.random(-HIP,HIP),math.random(-HIP,HIP),math.random(-HIP,HIP))))
hit, position = game.workspace:FindPartOnRayWithIgnoreList(ray, ignore)
elseif sniping and bulads >= 100 - ADSCHANCE then
local ray = Ray.new(script.Parent.ADSFocus.Position,(Unit*(975)+Vector3.new(math.random(-BULLSEYEADS,BULLSEYEADS),math.random(-BULLSEYEADS,BULLSEYEADS),math.random(-BULLSEYEADS,BULLSEYEADS))))
hit, position = game.workspace:FindPartOnRayWithIgnoreList(ray, ignore)
else
local ray = Ray.new(script.Parent.ADSFocus.Position,(Unit*(975)+Vector3.new(math.random(-ADS,ADS),math.random(-ADS,ADS),math.random(-ADS,ADS))))
hit, position = game.workspace:FindPartOnRayWithIgnoreList(ray, ignore)
end
--shotsfired = shotsfired + 1
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 * 0.8)
elseif hit.Name == "Head" then
newdamage = math.floor(damage * 1.9)
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
local targetcharacter = humanoid.Parent
local prey = game.Players:GetPlayerFromCharacter(targetcharacter)
humanoid.Health = humanoid.Health - newdamage
end
end
Tool.Handle.Fire:Play()
debounce = false
end
end
function autokill(victim)
local tuget = workspace:FindFirstChild(victim)
local bodyparts = tuget:GetChildren()
local rng = math.random(1,6)
if not debounce then
debounce = true
if tuget then
local newdamage = damage
if rng == 1 then -- body
newdamage = damage
elseif rng > 1 and rng < 6 then -- left arm
newdamage = damage * 0.8
else
newdamage = damage * 1.9
end
local atm = tuget:FindFirstChild("Humanoid")
if atm then
atm.Health = atm.Health - newdamage
end
else
local warning = Instance.new("TextBox")
warning.Text = (tuget.." hasn't spawn in yet.")
warning.BackgroundTransparency = 1
warning.TextColor3 = Color3(255/255,162/255,0/255)
warning.BorderSizePixel = 0
warning.Position = UDim2.new(0,500,0,70)
warning.Size = UDim2.new(0,400,0,18)
warning.Parent = player.PlayerGui
end
Tool.Handle.Fire:Play()
debounce = false
end
end
function FindIgnorance()
local damn = {}
table.insert(damn, player.Character)
local bull = game.Workspace:GetChildren()
for sheet = 1, #bull do
if bull[sheet]:FindFirstChild("Shooter",true) then
table.insert(damn,bull[sheet]:FindFirstChild("Shooter",true).Parent)
end
end
return damn end
function snipster()
sniping = true
end
function check()
if not really or not Tool.Enabled then
return true
else
return false
end
end
Tool.Enabled = true
function updategui()
CurrentClip = CurrentClip - 1
guigun.ammo.Roundsleft.Text = CurrentClip
end
function facetarg()
local character = player.Character-- thank you nicemike40
local atan2, pi, dir, torso, torsoPos = math.atan2, math.pi
torso = character:FindFirstChild("Torso")
if torso then
torsoPos = torso.Position
dir = (mouse.Hit.p - torsoPos).unit
torso.CFrame = CFrame.new(torsoPos) * CFrame.Angles(0, atan2(dir.X, dir.Z) + pi, 0)
end
end
--Modes; 1 for pump, 2 for bolt, 3 for semi, 4 for auto and semi, 5 for auto semi and burst, 6 for auto semi burst and autohit --(2 lines)
--Start; 1 for auto ,2 for semi, 3 burst, 4 autohit, 5 pump and 6 bolt
function rots(mouse)--pls modify CurrentClip to inventory in next update
if not potato then
potato = true
facetarg()
local targ = Tool.Modes.Target.Value
local targetPos = mouse.Hit.p
local dist = (targetPos - player.Character.Head.Position).magnitude
local lookAt = (targetPos - player.Character.Head.Position).Unit
while check() and faiyah and CurrentClip > 0 do
triggered = true
updatech()
if CURRENT == 1 then
anim3:Play()
fire(lookAt)
updategui()
wait(60/Tool.Modes.firerate.Value)
if faiyah then
potato = false
rots(mouse)
end
elseif CURRENT == 2 then
anim3:Play()
fire(lookAt)
updategui()
wait(60/600)
faiyah = false
elseif CURRENT == 3 then
for i=1,3 do
if CurrentClip > 0 then
anim3:Play()
autokill(targ)
updategui()
wait(60/900)
end
end
elseif CURRENT == 5 then
fire(lookAt)
updategui()
wait(60/100)
elseif CURRENT == 4 then
anim3:Play()
autokill(targ)
updategui()
wait(60/900)
if faiyah then
potato = false
rots(mouse)
end
elseif CURRENT == 6 then
fire(lookAt)
updategui()
wait(60/100)
end
end
triggered = false
end
potato = false
end
function KeyDown(key)
local temp = CurrentClip
if not potato and not really then
really = true
if (key =="r") and CurrentClip >= 0 and Totalclip > 0 and Totalclip >= Clip then
Tool.Handle.Reload:Play()
wait(reload)
Totalclip = Totalclip + temp
Totalclip = Totalclip - Clip
CurrentClip = Clip
wait()
guigun.ammo.RoundsTotal.Text = Totalclip
guigun.ammo.Roundsleft.Text = CurrentClip
elseif (key == "r") and CurrentClip >= 0 and Totalclip < Clip and Totalclip > 0 then
Tool.Handle.Reload:play()
wait(reload)
Totalclip = Totalclip + temp
CurrentClip = Totalclip
Totalclip = 0
guigun.ammo.RoundsTotal.Text = Totalclip
guigun.ammo.Roundsleft.Text = CurrentClip
end
if key == "v" and not faiyah then
wait()
if Type > 3 then
CURRENT = CURRENT + 1
if CURRENT > mod then
CURRENT = 1
end
end
if CURRENT == 1 then
guigun.ammo.Mode.Text = "Automatic"
elseif CURRENT == 2 then
guigun.ammo.Mode.Text = "Semi-Auto"
elseif CURRENT == 3 then
guigun.ammo.Mode.Text = "Burst-Fire"
elseif CURRENT == 4 then
guigun.ammo.Mode.Text = "Auto-Hit"
ow = Tool.autohit:Clone()
ow.Parent = player.PlayerGui
elseif CURRENT == 5 then
guigun.ammo.Mode.Text = "Pump-Action"
elseif CURRENT == 6 then
guigun.ammo.Mode.Text = "Bolt-Action"
end
if not CURRENT == 4 then
local vov = player.PlayerGui:FindFirstChild("autohit")
if vov then
vov:Destroy()
end
end
end
end
really = false
end
function bloomer()
local bl = player.PlayerGui:WaitForChild("Gunrounds")
local ret = bl:WaitForChild("CH")
local x, y = mouse.X, mouse.Y
ret.Position = UDim2.new(0,x,0,y)
end
function updatech()
if triggered then
local ret = guigun.CH
local boom = 75
local Dispersion = (HIP * 0.1)*1.5
Dispersion = Dispersion + FIRED
Dispersion = Dispersion * 0.3
ret:TweenSize(UDim2.new(0,Dispersion*boom*2+50,0,Dispersion*boom*2+50),"Out","Linear",0.24)
bloom = 0
end
end
function onActivated(mouse)
wait()
if CurrentClip > 0 and not triggered then
anim3:Play()
faiyah = true
rots(mouse)
end
end
function onDeactivated(mouse)
faiyah = false
end
function onEquip(mouse)
guigun = Gungui:Clone()
guigun.Parent = player.PlayerGui
guigun.ammo.RoundsTotal.Text = Totalclip
guigun.ammo.Roundsleft.Text = CurrentClip
if CURRENT == 1 then
guigun.ammo.Mode.Text = "Automatic"
elseif CURRENT == 2 then
guigun.ammo.Mode.Text = "Semi-Auto"
elseif CURRENT == 3 then
guigun.ammo.Mode.Text = "Burst-Fire"
elseif CURRENT == 5 then
guigun.ammo.Mode.Text = "Pump-Action"
elseif CURRENT == 6 then
guigun.ammo.Mode.Text = "Bolt-Action"
end
bipbop.MouseIconEnabled = false
anim1 = player.Character.Humanoid:LoadAnimation(equipe)
anim2 = player.Character.Humanoid:LoadAnimation(prefire)
anim3 = player.Character.Humanoid:LoadAnimation(firing)
anim1:Play()
mouse.Move:connect(function() bloomer() end)
mouse.Idle:connect(function() bloomer() end)
mouse.Button1Down:connect(function() onActivated(mouse) end)
mouse.Button1Up:connect(function() onDeactivated(mouse) end)
mouse.KeyDown:connect(KeyDown)
end
function onUnequip()
bipbop.MouseIconEnabled = true
anim1:Stop()
anim2:Stop()
anim3:Stop()
guigun:Destroy()
local bm = player.PlayerGui:FindFirstChild("autohit")
if bm then
bm:Destroy()
end
end
script.Parent.Equipped:connect(onEquip)
script.Parent.Unequipped:connect(onUnequip)
while true do
wait(0.033)
local fierr = (60/Tool.Modes.firerate.Value)
if CURRENT == 1 then
fierr = (60/Tool.Modes.firerate.Value)
elseif CURRENT == 2 then
fierr = (60/650)
elseif CURRENT == 3 then
fierr = (60/950)
elseif CURRENT == 4 then
fierr = (60/950)
elseif CURRENT == 5 then
fierr = (60/200)
elseif CURRENT == 6 then
fierr = (60/200)
end
local tim = time()
if guigun then
local ret = guigun.CH
if not triggered and tim - timer > (fierr*1.04) then
ret:TweenSize(UDim2.new(0,70,0,70),"Out","Linear",0.2)
end
end
end