local K=script.Parent:WaitForChild("\086\105\115\117\097\108\105\122\101\066\117\108\108\101\116")local U=require(Tool:WaitForChild("\083\101\116\116\105\110\103"))local E=Tool:WaitForChild("\071\117\110\083\099\114\105\112\116\095\083\101\114\118\101\114")local R=E:WaitForChild("\067\104\097\110\103\101\065\109\109\111\065\110\100\067\108\105\112")local t=E:WaitForChild("\073\110\102\108\105\099\116\084\097\114\103\101\116")local D=E:WaitForChild("\065\109\109\111")local J=E:WaitForChild("\067\108\105\112\115")local Z=script:WaitForChild("\071\117\110\071\085\073")local S local P local N local u local z local O local a=Handle if U.DualEnabled then O=Tool:WaitForChild("\072\097\110\100\108\101\050",2)if O==nil and U.DualEnabled then error("\"\068\117\097\108\" \115\101\116\116\105\110\103 \105\115 \101\110\097\098\108\101\100 \098\117\116 \"\072\097\110\100\108\101\050\" \105\115 \109\105\115\115\105\110\103\033")end end local A=false local C=true local B=false local l=false local h=false local y=D.Value local f=J.Value local i=U.MaxClip local G={}if U.IdleAnimationID~=nil or U.DualEnabled then S=Tool:WaitForChild("\073\100\108\101\065\110\105\109")S=Humanoid:LoadAnimation(S)end if U.FireAnimationID~=nil then P=Tool:WaitForChild("\070\105\114\101\065\110\105\109")P=Humanoid:LoadAnimation(P)end if U.ReloadAnimationID~=nil then N=Tool:WaitForChild("\082\101\108\111\097\100\065\110\105\109")N=Humanoid:LoadAnimation(N)end if U.ShotgunClipinAnimationID~=nil then u=Tool:WaitForChild("\083\104\111\116\103\117\110\067\108\105\112\105\110\065\110\105\109")u=Humanoid:LoadAnimation(u)end function wait(K)if K~=nil then local U=0 U=U+(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()while U<K do U=U+(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()end else(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:wait()end end function RayCast(K,U,E,R)local t,D=game.Workspace:FindPartOnRay(Ray.new(K,U*E),R)if t then if t.Transparency>.75 or t.Name=="\072\097\110\100\108\101"or t.Name=="\069\102\102\101\099\116"or t.Name=="\066\117\108\108\101\116"or t.Name=="\076\097\115\101\114"or string.lower(t.Name)=="\119\097\116\101\114"or t.Name=="\082\097\105\108"or t.Name=="\065\114\114\111\119"or t.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")and t.Parent.Humanoid.Health==0 or t.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")and(t.Parent:FindFirstChild("\084\069\065\077")and(TEAM and t.Parent.TEAM.Value==TEAM.Value))or t.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")and G[t.Parent.Humanoid]then t,D=RayCast(D+U*.01,U,E-(K-D).magnitude,R)end end return t,D end function ShakeCamera()if U.CameraShakingEnabled then local K=U.Intensity/(h and U.MouseSensitive or 1)for U=1,10,1 do local E=Camera.CoordinateFrame-Camera.CoordinateFrame.p local R=(Camera.CoordinateFrame.p-Camera.Focus.p).magnitude local t=(CFrame.new(Camera.Focus.p)*E)*CFrame.fromEulerAnglesXYZ((-K+math.random()*(K*2))/100,(-K+math.random()*(K*2))/100,0)Camera.CoordinateFrame=t*CFrame.new(0,0,R)wait()end end end function Fire(K)local E=U.Piercing G={}if P then P:Play(nil,nil,U.FireAnimationSpeed)end if not K.FireSound.Playing or not K.FireSound.Looped then K.FireSound:Play()script.Parent.Model.casing:FireServer()end local R=(Humanoid.Torso.CFrame*CFrame.new(0,1.5,0)).p local D=U.Spread*(h and 1-U.SpreadRedution or 1)local J=(CFrame.new(R,Mouse.Hit.p)*CFrame.Angles(math.rad(-D+math.random()*(D*2)),math.rad(-D+math.random()*(D*2)),0)).lookVector while E>=0 do local D,Z=RayCast(R,J,5000,Character)if not U.ExplosiveEnabled then if D and D.Parent then local K=D.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local R=D.Parent:FindFirstChild("\084\111\114\115\111")if K and(K.Health>0 and R)then t:FireServer(K,R,(D.Name=="\072\101\097\100"and U.HeadshotEnabled)and U.BaseDamage*U.HeadshotDamageMultiplier or U.BaseDamage,J,U.Knockback,U.Lifesteal,U.FlamingBullet)G[K]=true else E=0 end end else local K=Instance.new("\069\120\112\108\111\115\105\111\110")K.BlastRadius=U.Radius K.BlastPressure=0 K.Position=Z K.Parent=Workspace.CurrentCamera K.Hit:connect(function(K)if K and(K.Parent and K.Name=="\084\111\114\115\111")then local E=K.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local R=K.Parent:FindFirstChild("\084\111\114\115\111")if E and(E.Health>0 and R)then t:FireServer(E,R,(K.Name=="\072\101\097\100"and U.HeadshotEnabled)and U.BaseDamage*U.HeadshotDamageMultiplier or U.BaseDamage,J,U.Knockback,U.Lifesteal,U.FlamingBullet)end end end)E=0 end E=D and E-1 or-1 script.Parent.BulletVisualizerScript.Visualize:Fire(nil,K,U.MuzzleOffset,Z,script.MuzzleEffect,script.HitEffect,U.HitSoundIDs[math.random(1,#U.HitSoundIDs)],{U.ExplosiveEnabled,U.BlastRadius;U.BlastPressure},{U.BulletSpeed;U.BulletSize;U.BulletColor,U.BulletTransparency,U.BulletMaterial;U.FadeTime},false,E==-1 and U.VisualizerEnabled or false)script.Parent.VisualizeBullet:FireServer(K,U.MuzzleOffset,Z,script.MuzzleEffect,script.HitEffect,U.HitSoundIDs[math.random(1,#U.HitSoundIDs)],{U.ExplosiveEnabled;U.BlastRadius,U.BlastPressure},{U.BulletSpeed,U.BulletSize;U.BulletColor;U.BulletTransparency;U.BulletMaterial;U.FadeTime},true,E==-1 and U.VisualizerEnabled or false)R=Z+J*.01 end end function Reload()if C and(not l and((f>0 or not U.LimitedClipEnabled)and y<U.AmmoPerClip))then l=true if h then Workspace.CurrentCamera.FieldOfView=70 Z.Scope.Visible=false game.Players.LocalPlayer.CameraMode=Enum.CameraMode.Classic script["\077\111\117\115\101 \083\101\110\115\105\116\105\118\105\116\121"].Disabled=true h=false Mouse.Icon="\114\098\120\097\115\115\101\116\105\100\058\047\047"..U.MouseIconID end UpdateGUI()if U.ShotgunReload then for K=1,U.AmmoPerClip-y,1 do if u then u:Play(nil,nil,U.ShotgunClipinAnimationSpeed)end Handle.ShotgunClipin:Play()wait(U.ShellClipinSpeed)end end if N then N:Play(nil,nil,U.ReloadAnimationSpeed)end Handle.ReloadSound:Play()script.Parent.Model.reload:FireServer()wait(U.ReloadTime)if U.LimitedClipEnabled then f=f-1 end y=U.AmmoPerClip R:FireServer(y,f)l=false UpdateGUI()end end function UpdateGUI()Z.Frame.Ammo.Fill:TweenSizeAndPosition(UDim2.new(y/U.AmmoPerClip,0,1,0),UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,.25,true)Z.Frame.Clips.Fill:TweenSizeAndPosition(UDim2.new(f/U.MaxClip,0,1,0),UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quint,.25,true)Z.Frame.Ammo.Current.Text=y Z.Frame.Ammo.Max.Text=U.AmmoPerClip Z.Frame.Clips.Current.Text=f Z.Frame.Clips.Max.Text=U.MaxClip Z.Frame.Ammo.Current.Visible=not l Z.Frame.Ammo.Max.Visible=not l Z.Frame.Ammo.Frame.Visible=not l Z.Frame.Ammo.Reloading.Visible=l Z.Frame.Clips.Current.Visible=not(f<=0)Z.Frame.Clips.Max.Visible=not(f<=0)Z.Frame.Clips.Frame.Visible=not(f<=0)Z.Frame.Clips.NoMoreClip.Visible=f<=0 Z.Frame.Clips.Visible=U.LimitedClipEnabled Z.Frame.Size=U.LimitedClipEnabled and UDim2.new(0,250,0,100)or UDim2.new(0,250,0,55)Z.Frame.Position=U.LimitedClipEnabled and UDim2.new(1,-260,1,-110)or UDim2.new(1,-260,1,-65)end Mouse.Button1Down:connect(function()B=true local K=false if A and(C and(B and(not l and(y>0 and Humanoid.Health>0))))then C=false if U.ChargedShotEnabled then if a:FindFirstChild("\067\104\097\114\103\101\083\111\117\110\100")then a.ChargeSound:Play()end wait(U.ChargingTime)K=true end if U.MinigunEnabled then if a:FindFirstChild("\087\105\110\100\085\112")then a.WindUp:Play()end wait(U.DelayBeforeFiring)end while A and(not l and((B or K)and(y>0 and Humanoid.Health>0)))do K=false for K=1,U.BurstFireEnabled and U.BulletPerBurst or 1,1 do Spawn(ShakeCamera)for K=1,U.ShotgunEnabled and U.BulletPerShot or 1,1 do Fire(a)end y=y-1 R:FireServer(y,f)UpdateGUI()if U.BurstFireEnabled then wait(U.BurstRate)end if y<=0 then break end end a=(a==Handle and U.DualEnabled)and O or Handle wait(U.FireRate)if not U.Auto then break end end if a.FireSound.Playing and a.FireSound.Looped then a.FireSound:Stop()end if U.MinigunEnabled then if a:FindFirstChild("\087\105\110\100\068\111\119\110")then a.WindDown:Play()end wait(U.DelayAfterFiring)end C=true if y<=0 then Reload()end end end)Mouse.Button1Up:connect(function()B=false end)R.OnClientEvent:connect(function(K,U)y=K f=U UpdateGUI()end)Tool.Equipped:connect(function(K)A=true UpdateGUI()if U.AmmoPerClip~=math.huge then Z.Parent=Player.PlayerGui end K.Icon="\114\098\120\097\115\115\101\116\105\100\058\047\047"..U.MouseIconID if S then S:Play(nil,nil,U.IdleAnimationSpeed)end K.KeyDown:connect(function(K)if string.lower(K)=="\114"then Reload()elseif string.lower(K)=="\101"then if not l and(h==false and U.SniperEnabled)then Workspace.CurrentCamera.FieldOfView=U.FieldOfView Z.Scope.Visible=true game.Players.LocalPlayer.CameraMode=Enum.CameraMode.LockFirstPerson script["\077\111\117\115\101 \083\101\110\115\105\116\105\118\105\116\121"].Disabled=false h=true Mouse.Icon="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\063\105\100\061\049\056\055\055\052\054\055\057\057"else Workspace.CurrentCamera.FieldOfView=70 Z.Scope.Visible=false game.Players.LocalPlayer.CameraMode=Enum.CameraMode.Classic script["\077\111\117\115\101 \083\101\110\115\105\116\105\118\105\116\121"].Disabled=true h=false Mouse.Icon="\114\098\120\097\115\115\101\116\105\100\058\047\047"..U.MouseIconID end end end)if U.DualEnabled and not Workspace.FilteringEnabled then O.CanCollide=false local K=Tool.Parent:FindFirstChild("\076\101\102\116 \065\114\109")local U=Tool.Parent:FindFirstChild("\082\105\103\104\116 \065\114\109")if U then local E=U:WaitForChild("\082\105\103\104\116\071\114\105\112",.01)if E then z=E:Clone()z.Name="\076\101\102\116\071\114\105\112"z.Part0=K z.Part1=O z.Parent=K end end end end)Tool.Unequipped:connect(function()A=false Z.Parent=script if S then S:Stop()end if h then Workspace.CurrentCamera.FieldOfView=70 Z.Scope.Visible=false game.Players.LocalPlayer.CameraMode=Enum.CameraMode.Classic script["\077\111\117\115\101 \083\101\110\115\105\116\105\118\105\116\121"].Disabled=true h=false Mouse.Icon="\114\098\120\097\115\115\101\116\105\100\058\047\047"..U.MouseIconID end if U.DualEnabled and not Workspace.FilteringEnabled then O.CanCollide=true if z then z:Destroy()end end end)Humanoid.Died:connect(function()A=false Z.Parent=script if S then S:Stop()end if h then Workspace.CurrentCamera.FieldOfView=70 Z.Scope.Visible=false game.Players.LocalPlayer.CameraMode=Enum.CameraMode.Classic script["\077\111\117\115\101 \083\101\110\115\105\116\105\118\105\116\121"].Disabled=true h=false Mouse.Icon="\114\098\120\097\115\115\101\116\105\100\058\047\047"..U.MouseIconID end if U.DualEnabled and not Workspace.FilteringEnabled then O.CanCollide=true if z then z:Destroy()end end end)

local VisualizeBullet = script.Parent:WaitForChild("VisualizeBullet")
local Module = require(Tool:WaitForChild("Setting"))
local GunScript_Server = Tool:WaitForChild("GunScript_Server")
local ChangeAmmoAndClip = GunScript_Server:WaitForChild("ChangeAmmoAndClip")
local InflictTarget = GunScript_Server:WaitForChild("InflictTarget")
local AmmoValue = GunScript_Server:WaitForChild("Ammo")
local ClipsValue = GunScript_Server:WaitForChild("Clips")
local GUI = script:WaitForChild("GunGUI")
local IdleAnim
local FireAnim
local ReloadAnim
local ShotgunClipinAnim
local Grip2
local Handle2
local HandleToFire = Handle

if Module.DualEnabled then
	Handle2 = Tool:WaitForChild("Handle2",2)
	if Handle2 == nil and Module.DualEnabled then error("\"Dual\" setting is enabled but \"Handle2\" is missing!") end
end

local Equipped = false
local Enabled = true
local Down = false
local Reloading = false
local AimDown = false
local Ammo = AmmoValue.Value
local Clips = ClipsValue.Value
local MaxClip = Module.MaxClip
local PiercedHumanoid = {}

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
	IdleAnim = Tool:WaitForChild("IdleAnim")
	IdleAnim = Humanoid:LoadAnimation(IdleAnim)
end
if Module.FireAnimationID ~= nil then
	FireAnim = Tool:WaitForChild("FireAnim")
	FireAnim = Humanoid:LoadAnimation(FireAnim)
end
if Module.ReloadAnimationID ~= nil then
	ReloadAnim = Tool:WaitForChild("ReloadAnim")
	ReloadAnim = Humanoid:LoadAnimation(ReloadAnim)
end
if Module.ShotgunClipinAnimationID ~= nil then
	ShotgunClipinAnim = Tool:WaitForChild("ShotgunClipinAnim")
	ShotgunClipinAnim = Humanoid:LoadAnimation(ShotgunClipinAnim)
end

function wait(TimeToWait)
	if TimeToWait ~= nil then
		local TotalTime = 0
		TotalTime = TotalTime + game:GetService("RunService").Heartbeat:wait()
		while TotalTime < TimeToWait do
			TotalTime = TotalTime + game:GetService("RunService").Heartbeat:wait()
		end
	else
		game:GetService("RunService").Heartbeat:wait()
	end
end

function RayCast(Start,Direction,Range,Ignore)
	local Hit,EndPos = game.Workspace:FindPartOnRay(Ray.new(Start,Direction*Range),Ignore)
	if Hit then
		if (Hit.Transparency > 0.75
			or Hit.Name == "Handle"
			or Hit.Name == "Effect"
			or Hit.Name == "Bullet"
			or Hit.Name == "Laser"
			or string.lower(Hit.Name) == "water"
			or Hit.Name == "Rail"
			or Hit.Name == "Arrow"
			or (Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent.Humanoid.Health == 0)
			or (Hit.Parent:FindFirstChild("Humanoid") and Hit.Parent:FindFirstChild("TEAM") and TEAM and Hit.Parent.TEAM.Value == TEAM.Value))
			or (Hit.Parent:FindFirstChild("Humanoid") and PiercedHumanoid[Hit.Parent.Humanoid]) then
			Hit,EndPos = RayCast(EndPos+(Direction*.01),Direction,Range-((Start-EndPos).magnitude),Ignore)
		end
	end
	return Hit,EndPos
end

function ShakeCamera()
	if Module.CameraShakingEnabled then
		local Intensity = Module.Intensity/(AimDown and Module.MouseSensitive or 1)
		for i = 1, 10 do
			local cam_rot = Camera.CoordinateFrame - Camera.CoordinateFrame.p
			local cam_scroll = (Camera.CoordinateFrame.p - Camera.Focus.p).magnitude
			local ncf = CFrame.new(Camera.Focus.p)*cam_rot*CFrame.fromEulerAnglesXYZ((-Intensity+(math.random()*(Intensity*2)))/100, (-Intensity+(math.random()*(Intensity*2)))/100, 0)
			Camera.CoordinateFrame = ncf*CFrame.new(0, 0, cam_scroll)
			wait()
		end
	end
end

function Fire(ShootingHandle)
	local PierceAvailable = Module.Piercing
	PiercedHumanoid = {}
	if FireAnim then FireAnim:Play(nil,nil,Module.FireAnimationSpeed) end
	if not ShootingHandle.FireSound.Playing or not ShootingHandle.FireSound.Looped then ShootingHandle.FireSound:Play() script.Parent.Model.casing:FireServer() end
	local Start = (Humanoid.Torso.CFrame * CFrame.new(0,1.5,0)).p--(Handle.CFrame * CFrame.new(Module.MuzzleOffset.X,Module.MuzzleOffset.Y,Module.MuzzleOffset.Z)).p
	local Spread = Module.Spread*(AimDown and 1-Module.SpreadRedution or 1)
	local Direction = (CFrame.new(Start,Mouse.Hit.p) * CFrame.Angles(math.rad(-Spread+(math.random()*(Spread*2))),math.rad(-Spread+(math.random()*(Spread*2))),0)).lookVector
	while PierceAvailable >= 0 do
		local Hit,EndPos = RayCast(Start,Direction,5000,Character)
		if not Module.ExplosiveEnabled then
			if Hit and Hit.Parent then
				local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
				local TargetTorso = Hit.Parent:FindFirstChild("Torso")
				--local TargetTEAM = Hit.Parent:FindFirstChild("TEAM")
				if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
					--if TargetTEAM and TargetTEAM.Value ~= TEAM.Value then
						InflictTarget:FireServer(TargetHumanoid,
												TargetTorso,
												(Hit.Name == "Head" and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage,
												Direction,
												Module.Knockback,
												Module.Lifesteal,
												Module.FlamingBullet)
						PiercedHumanoid[TargetHumanoid] = true
					--end
				else
					PierceAvailable = 0
				end
			end
		else
			local Explosion = Instance.new("Explosion")
			Explosion.BlastRadius = Module.Radius
			Explosion.BlastPressure = 0
			Explosion.Position = EndPos
			Explosion.Parent = Workspace.CurrentCamera
			Explosion.Hit:connect(function(Hit)
				if Hit and Hit.Parent and Hit.Name == "Torso" then
					local TargetHumanoid = Hit.Parent:FindFirstChild("Humanoid")
					local TargetTorso = Hit.Parent:FindFirstChild("Torso")
					--local TargetTEAM = Hit.Parent:FindFirstChild("TEAM")
					if TargetHumanoid and TargetHumanoid.Health > 0 and TargetTorso then
						--if TargetTEAM and TargetTEAM.Value ~= TEAM.Value then
							InflictTarget:FireServer(TargetHumanoid,
													TargetTorso,
													(Hit.Name == "Head" and Module.HeadshotEnabled) and Module.BaseDamage * Module.HeadshotDamageMultiplier or Module.BaseDamage,
													Direction,
													Module.Knockback,
													Module.Lifesteal,
													Module.FlamingBullet)
						--end
					end
				end
			end)
			PierceAvailable = 0
		end
		PierceAvailable = Hit and (PierceAvailable - 1) or -1
		script.Parent.BulletVisualizerScript.Visualize:Fire(nil,ShootingHandle,
																	Module.MuzzleOffset,
																	EndPos,
																	script.MuzzleEffect,
																	script.HitEffect,
																	Module.HitSoundIDs[math.random(1,#Module.HitSoundIDs)],
																	{Module.ExplosiveEnabled,Module.BlastRadius,Module.BlastPressure},
																	{Module.BulletSpeed,Module.BulletSize,Module.BulletColor,Module.BulletTransparency,Module.BulletMaterial,Module.FadeTime},
																	false,
																	PierceAvailable == -1 and Module.VisualizerEnabled or false)
		script.Parent.VisualizeBullet:FireServer(ShootingHandle,
														Module.MuzzleOffset,
														EndPos,
														script.MuzzleEffect,
														script.HitEffect,
														Module.HitSoundIDs[math.random(1,#Module.HitSoundIDs)],
														{Module.ExplosiveEnabled,Module.BlastRadius,Module.BlastPressure},
														{Module.BulletSpeed,Module.BulletSize,Module.BulletColor,Module.BulletTransparency,Module.BulletMaterial,Module.FadeTime},
														true,
														PierceAvailable == -1 and Module.VisualizerEnabled or false)
		Start = EndPos + (Direction*0.01)
	end
end

function Reload()
	if Enabled and not Reloading and (Clips > 0 or not Module.LimitedClipEnabled) and Ammo < Module.AmmoPerClip then
		Reloading = true
		if AimDown then
			Workspace.CurrentCamera.FieldOfView = 70
			--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui")
			if GUI then GUI:Destroy() end]]
			GUI.Scope.Visible = false
			game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
			script["Mouse Sensitivity"].Disabled = true
			AimDown = false
			Mouse.Icon = "rbxassetid://"..Module.MouseIconID
		end
		UpdateGUI()
		if Module.ShotgunReload then
			for i = 1,(Module.AmmoPerClip - Ammo) do
				if ShotgunClipinAnim then ShotgunClipinAnim:Play(nil,nil,Module.ShotgunClipinAnimationSpeed) end
				Handle.ShotgunClipin:Play()
				wait(Module.ShellClipinSpeed)
			end
		end
		if ReloadAnim then ReloadAnim:Play(nil,nil,Module.ReloadAnimationSpeed) end
		Handle.ReloadSound:Play() script.Parent.Model.reload:FireServer()
		wait(Module.ReloadTime)
		if Module.LimitedClipEnabled then Clips = Clips - 1 end
		Ammo = Module.AmmoPerClip
		ChangeAmmoAndClip:FireServer(Ammo,Clips)
		Reloading = false
		UpdateGUI()
	end
end

function UpdateGUI()
	GUI.Frame.Ammo.Fill:TweenSizeAndPosition(UDim2.new(Ammo/Module.AmmoPerClip,0,1,0), UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true)
	GUI.Frame.Clips.Fill:TweenSizeAndPosition(UDim2.new(Clips/Module.MaxClip,0,1,0), UDim2.new(0,0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true)
	GUI.Frame.Ammo.Current.Text = Ammo
	GUI.Frame.Ammo.Max.Text = Module.AmmoPerClip
	GUI.Frame.Clips.Current.Text = Clips
	GUI.Frame.Clips.Max.Text = Module.MaxClip

	GUI.Frame.Ammo.Current.Visible = not Reloading
	GUI.Frame.Ammo.Max.Visible = not Reloading
	GUI.Frame.Ammo.Frame.Visible = not Reloading
	GUI.Frame.Ammo.Reloading.Visible = Reloading

	GUI.Frame.Clips.Current.Visible = not (Clips <= 0)
	GUI.Frame.Clips.Max.Visible = not (Clips <= 0)
	GUI.Frame.Clips.Frame.Visible = not (Clips <= 0)
	GUI.Frame.Clips.NoMoreClip.Visible = (Clips <= 0)
	
	GUI.Frame.Clips.Visible = Module.LimitedClipEnabled
	GUI.Frame.Size = Module.LimitedClipEnabled and UDim2.new(0,250,0,100) or UDim2.new(0,250,0,55)
	GUI.Frame.Position = Module.LimitedClipEnabled and UDim2.new(1,-260,1,-110)or UDim2.new(1,-260,1,-65)
end

Mouse.Button1Down:connect(function()
	Down = true
	local IsChargedShot = false
	if Equipped and Enabled and Down and not Reloading and Ammo > 0 and Humanoid.Health > 0 then
		Enabled = false
		if Module.ChargedShotEnabled then
			if HandleToFire:FindFirstChild("ChargeSound") then HandleToFire.ChargeSound:Play() end
			wait(Module.ChargingTime)
			IsChargedShot = true
		end
		if Module.MinigunEnabled then
			if HandleToFire:FindFirstChild("WindUp") then HandleToFire.WindUp:Play() end
			wait(Module.DelayBeforeFiring)
		end
		while Equipped and not Reloading and (Down or IsChargedShot) and Ammo > 0 and Humanoid.Health > 0 do
			IsChargedShot = false
			for i = 1,(Module.BurstFireEnabled and Module.BulletPerBurst or 1) do
				Spawn(ShakeCamera)
				for x = 1,(Module.ShotgunEnabled and Module.BulletPerShot or 1) do
					Fire(HandleToFire)
				end
				Ammo = Ammo - 1
				ChangeAmmoAndClip:FireServer(Ammo,Clips)
				UpdateGUI()
				if Module.BurstFireEnabled then wait(Module.BurstRate) end
				if Ammo <= 0 then break end
			end
			HandleToFire = (HandleToFire == Handle and Module.DualEnabled) and Handle2 or Handle
			wait(Module.FireRate)
			if not Module.Auto then break end
		end
		if HandleToFire.FireSound.Playing and HandleToFire.FireSound.Looped then HandleToFire.FireSound:Stop() end
		if Module.MinigunEnabled then
			if HandleToFire:FindFirstChild("WindDown") then HandleToFire.WindDown:Play() end
			wait(Module.DelayAfterFiring)
		end
		Enabled = true
		if Ammo <= 0 then Reload() end
	end
end)
Mouse.Button1Up:connect(function()
	Down = false
end)

ChangeAmmoAndClip.OnClientEvent:connect(function(ChangedAmmo,ChangedClips)
	Ammo = ChangedAmmo
	Clips = ChangedClips
	UpdateGUI()
end)
Tool.Equipped:connect(function(TempMouse)
	Equipped = true
	UpdateGUI()
	if Module.AmmoPerClip ~= math.huge then GUI.Parent = Player.PlayerGui end
	TempMouse.Icon = "rbxassetid://"..Module.MouseIconID
	if IdleAnim then IdleAnim:Play(nil,nil,Module.IdleAnimationSpeed) end
	TempMouse.KeyDown:connect(function(Key)
		if string.lower(Key) == "r" then
			Reload()
		elseif string.lower(Key) == "e" then
			if not Reloading and AimDown == false and Module.SniperEnabled then
				Workspace.CurrentCamera.FieldOfView = Module.FieldOfView
				--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui") or Tool.ZoomGui:Clone()
				GUI.Parent = game.Players.LocalPlayer.PlayerGui]]
				GUI.Scope.Visible = true
				game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
				script["Mouse Sensitivity"].Disabled = false
				AimDown = true
				Mouse.Icon="http://www.roblox.com/asset?id=187746799"
			else
				Workspace.CurrentCamera.FieldOfView = 70
				--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui")
				if GUI then GUI:Destroy() end]]
				GUI.Scope.Visible = false
				game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
				script["Mouse Sensitivity"].Disabled = true
				AimDown = false
				Mouse.Icon = "rbxassetid://"..Module.MouseIconID
			end
		end
	end)
	if Module.DualEnabled and not Workspace.FilteringEnabled then
		Handle2.CanCollide = false
		local LeftArm = Tool.Parent:FindFirstChild("Left Arm")
		local RightArm = Tool.Parent:FindFirstChild("Right Arm")
		if RightArm then
			local Grip = RightArm:WaitForChild("RightGrip",0.01)
			if Grip then
				Grip2 = Grip:Clone()
				Grip2.Name = "LeftGrip"
				Grip2.Part0 = LeftArm
				Grip2.Part1 = Handle2
				--Grip2.C1 = Grip2.C1:inverse()
				Grip2.Parent = LeftArm
			end
		end
	end
end)
Tool.Unequipped:connect(function()
	Equipped = false
	GUI.Parent = script
	if IdleAnim then IdleAnim:Stop() end
		if AimDown then
			Workspace.CurrentCamera.FieldOfView = 70
			--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui")
			if GUI then GUI:Destroy() end]]
			GUI.Scope.Visible = false
			game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
			script["Mouse Sensitivity"].Disabled = true
			AimDown = false
			Mouse.Icon = "rbxassetid://"..Module.MouseIconID
		end
	if Module.DualEnabled and not Workspace.FilteringEnabled then
		Handle2.CanCollide = true
		if Grip2 then Grip2:Destroy() end
	end
end)
Humanoid.Died:connect(function()
	Equipped = false
	GUI.Parent = script
	if IdleAnim then IdleAnim:Stop() end
		if AimDown then
			Workspace.CurrentCamera.FieldOfView = 70
			--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui")
			if GUI then GUI:Destroy() end]]
			GUI.Scope.Visible = false
			game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
			script["Mouse Sensitivity"].Disabled = true
			AimDown = false
			Mouse.Icon = "rbxassetid://"..Module.MouseIconID
		end
	if Module.DualEnabled and not Workspace.FilteringEnabled then
		Handle2.CanCollide = true
		if Grip2 then Grip2:Destroy() end
	end
end)
