--Viewmodel

if Module.VMIdleAnimationID ~= nil then
	local VMIdleAnim = Instance.new("Animation",Tool)
	VMIdleAnim.Name = "VMIdleAnim"
	VMIdleAnim.AnimationId = "rbxassetid://"..Module.VMIdleAnimationID
end
if Module.VMFireAnimationID ~= nil then
	local VMFireAnim = Instance.new("Animation",Tool)
	VMFireAnim.Name = "VMFireAnim"
	VMFireAnim.AnimationId = "rbxassetid://"..Module.VMFireAnimationID
end
if Module.VMReloadAnimationID ~= nil then
	local VMReloadAnim = Instance.new("Animation",Tool)
	VMReloadAnim.Name = "VMReloadAnim"
	VMReloadAnim.AnimationId = "rbxassetid://"..Module.VMReloadAnimationID
end
if Module.VMShotgunClipinAnimationID ~= nil then
	local VMShotgunClipinAnim = Instance.new("Animation",Tool)
	VMShotgunClipinAnim.Name = "VMShotgunClipinAnim"
	VMShotgunClipinAnim.AnimationId = "rbxassetid://"..Module.VMShotgunClipinAnimationID
end
if Module.VMShotgunPumpinAnimationID ~= nil then
	local VMShotgunPumpinAnim = Instance.new("Animation",Tool)
	VMShotgunPumpinAnim.Name = "VMShotgunPumpinAnim"
	VMShotgunPumpinAnim.AnimationId = "rbxassetid://"..Module.VMShotgunPumpinAnimationID
end
if Module.VMHoldDownAnimationID ~= nil then
	local VMHoldDownAnim = Instance.new("Animation",Tool)
	VMHoldDownAnim.Name = "VMHoldDownAnim"
	VMHoldDownAnim.AnimationId = "rbxassetid://"..Module.VMHoldDownAnimationID
end
if Module.VMEquippedAnimationID ~= nil then
	local VMEquippedAnim = Instance.new("Animation",Tool)
	VMEquippedAnim.Name = "VMEquippedAnim"
	VMEquippedAnim.AnimationId = "rbxassetid://"..Module.VMEquippedAnimationID
end
if Module.SecondaryFireAnimationEnabled and Module.VMSecondaryFireAnimationID ~= nil then
	local VMSecondaryFireAnim = Instance.new("Animation",Tool)
	VMSecondaryFireAnim.Name = "VMSecondaryFireAnim"
	VMSecondaryFireAnim.AnimationId = "rbxassetid://"..Module.VMSecondaryFireAnimationID
end
if Module.VMSecondaryShotgunPump and Module.VMSecondaryShotgunPumpinAnimationID ~= nil then
	local VMSecondaryShotgunPumpinAnim = Instance.new("Animation",Tool)
	VMSecondaryShotgunPumpinAnim.Name = "VMSecondaryShotgunPumpinAnim"
	VMSecondaryShotgunPumpinAnim.AnimationId = "rbxassetid://"..Module.VMSecondaryShotgunPumpinAnimationID
end
if Module.TacticalReloadAnimationEnabled and Module.VMTacticalReloadAnimationID ~= nil then
	local VMTacticalReloadAnim = Instance.new("Animation",Tool)
	VMTacticalReloadAnim.Name = "VMTacticalReloadAnim"
	VMTacticalReloadAnim.AnimationId = "rbxassetid://"..Module.VMTacticalReloadAnimationID
end
if Module.InspectAnimationEnabled and Module.VMInspectAnimationID ~= nil then
	local VMInspectAnim = Instance.new("Animation",Tool)
	VMInspectAnim.Name = "VMInspectAnim"
	VMInspectAnim.AnimationId = "rbxassetid://"..Module.VMInspectAnimationID
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)
