local i=require(Tool:WaitForChild("\083\101\116\116\105\110\103"))local c=script:WaitForChild("\067\104\097\110\103\101\077\097\103\065\110\100\065\109\109\111")local K local J if i.DualEnabled then J=Tool:WaitForChild("\072\097\110\100\108\101\050",1)if J==nil and i.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 Q=script:FindFirstChild("\077\097\103")or Instance.new("\078\117\109\098\101\114\086\097\108\117\101",script)Q.Name="\077\097\103"Q.Value=i.AmmoPerMag local o=script:FindFirstChild("\065\109\109\111")or Instance.new("\078\117\109\098\101\114\086\097\108\117\101",script)o.Name="\065\109\109\111"o.Value=i.LimitedAmmoEnabled and i.Ammo or 0 if i.IdleAnimationID~=nil or i.DualEnabled then local c=Instance.new("\065\110\105\109\097\116\105\111\110",Tool)c.Name="\073\100\108\101\065\110\105\109"c.AnimationId="\114\098\120\097\115\115\101\116\105\100\058\047\047"..(i.DualEnabled and 53610688 or i.IdleAnimationID)end if i.FireAnimationID~=nil then local c=Instance.new("\065\110\105\109\097\116\105\111\110",Tool)c.Name="\070\105\114\101\065\110\105\109"c.AnimationId="\114\098\120\097\115\115\101\116\105\100\058\047\047"..i.FireAnimationID end if i.ReloadAnimationID~=nil then local c=Instance.new("\065\110\105\109\097\116\105\111\110",Tool)c.Name="\082\101\108\111\097\100\065\110\105\109"c.AnimationId="\114\098\120\097\115\115\101\116\105\100\058\047\047"..i.ReloadAnimationID end if i.ShotgunClipinAnimationID~=nil then local c=Instance.new("\065\110\105\109\097\116\105\111\110",Tool)c.Name="\083\104\111\116\103\117\110\067\108\105\112\105\110\065\110\105\109"c.AnimationId="\114\098\120\097\115\115\101\116\105\100\058\047\047"..i.ShotgunClipinAnimationID end if i.HoldDownAnimationID~=nil then local c=Instance.new("\065\110\105\109\097\116\105\111\110",Tool)c.Name="\072\111\108\100\068\111\119\110\065\110\105\109"c.AnimationId="\114\098\120\097\115\115\101\116\105\100\058\047\047"..i.HoldDownAnimationID end if i.EquippedAnimationID~=nil then local c=Instance.new("\065\110\105\109\097\116\105\111\110",Tool)c.Name="\069\113\117\105\112\112\101\100\065\110\105\109"c.AnimationId="\114\098\120\097\115\115\101\116\105\100\058\047\047"..i.EquippedAnimationID end c.OnServerEvent:connect(function(i,c,K)Q.Value=c o.Value=K end)Tool.Equipped:connect(function()if i.DualEnabled and workspace.FilteringEnabled then J.CanCollide=false local i=Tool.Parent:FindFirstChild("\076\101\102\116 \065\114\109")or Tool.Parent:FindFirstChild("\076\101\102\116\072\097\110\100")local c=Tool.Parent:FindFirstChild("\082\105\103\104\116 \065\114\109")or Tool.Parent:FindFirstChild("\082\105\103\104\116\072\097\110\100")if c then local Q=c:WaitForChild("\082\105\103\104\116\071\114\105\112",.01)if Q then K=Q:Clone()K.Name="\076\101\102\116\071\114\105\112"K.Part0=i K.Part1=J K.Parent=i end end end end)Tool.Unequipped:connect(function()if i.DualEnabled and workspace.FilteringEnabled then J.CanCollide=true if K then K:Destroy()end end end)

local Module = require(Tool:WaitForChild("Setting"))
local ChangeMagAndAmmo = script:WaitForChild("ChangeMagAndAmmo")
local Grip2
local Handle2

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

local MagValue = script:FindFirstChild("Mag") or Instance.new("NumberValue",script)
MagValue.Name = "Mag"
MagValue.Value = Module.AmmoPerMag
local AmmoValue = script:FindFirstChild("Ammo") or Instance.new("NumberValue",script)
AmmoValue.Name = "Ammo"
AmmoValue.Value = Module.LimitedAmmoEnabled and Module.Ammo or 0

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
	local IdleAnim = Instance.new("Animation",Tool)
	IdleAnim.Name = "IdleAnim"
	IdleAnim.AnimationId = "rbxassetid://"..(Module.DualEnabled and 53610688 or Module.IdleAnimationID)
end
if Module.FireAnimationID ~= nil then
	local FireAnim = Instance.new("Animation",Tool)
	FireAnim.Name = "FireAnim"
	FireAnim.AnimationId = "rbxassetid://"..Module.FireAnimationID
end
if Module.ReloadAnimationID ~= nil then
	local ReloadAnim = Instance.new("Animation",Tool)
	ReloadAnim.Name = "ReloadAnim"
	ReloadAnim.AnimationId = "rbxassetid://"..Module.ReloadAnimationID
end
if Module.ShotgunClipinAnimationID ~= nil then
	local ShotgunClipinAnim = Instance.new("Animation",Tool)
	ShotgunClipinAnim.Name = "ShotgunClipinAnim"
	ShotgunClipinAnim.AnimationId = "rbxassetid://"..Module.ShotgunClipinAnimationID
end
if Module.HoldDownAnimationID ~= nil then
	local HoldDownAnim = Instance.new("Animation",Tool)
	HoldDownAnim.Name = "HoldDownAnim"
	HoldDownAnim.AnimationId = "rbxassetid://"..Module.HoldDownAnimationID
end
if Module.EquippedAnimationID ~= nil then
	local EquippedAnim = Instance.new("Animation",Tool)
	EquippedAnim.Name = "EquippedAnim"
	EquippedAnim.AnimationId = "rbxassetid://"..Module.EquippedAnimationID
end

ChangeMagAndAmmo.OnServerEvent:connect(function(Player,Mag,Ammo)
	MagValue.Value = Mag
	AmmoValue.Value = Ammo
end)

Tool.Equipped:connect(function()
	--Player = game.Players:GetPlayerFromCharacter(Tool.Parent)
	--Character = Tool.Parent
	--Humanoid = Character:FindFirstChild("Humanoid")
	if Module.DualEnabled and workspace.FilteringEnabled then
		Handle2.CanCollide = false
		local LeftArm = Tool.Parent:FindFirstChild("Left Arm") or Tool.Parent:FindFirstChild("LeftHand")
		local RightArm = Tool.Parent:FindFirstChild("Right Arm") or Tool.Parent:FindFirstChild("RightHand")
		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()
	if Module.DualEnabled and workspace.FilteringEnabled then
		Handle2.CanCollide = true
		if Grip2 then Grip2:Destroy() end
	end
end)
