function ReloadAnim()TweenJoint(LWeld2,CF(),CF(),Sine,.15)TweenJoint(RWeld2,CF(),CF(),Sine,.15)local P=S.ReloadTime/2 local p={}for P,W in pairs(Gun:GetChildren())do if W.Name=="\077\097\103"and W:IsA("\066\097\115\101\080\097\114\116")then INSERT(p,{Original=W,Clone1=W:Clone();Clone2=W:Clone()})end end local W=nil local u=nil local Y={function()for P,W in pairs(p)do W.Original.Transparency=1 W.Clone1.Parent=Gun_Ignore W.Clone1.CanCollide=true if P~=1 then local P=Instance.new("\087\101\108\100")P.Part0=p[1].Clone1 P.Part1=W.Clone1 P.C0=p[1].Clone1.CFrame:toObjectSpace(W.Clone1.CFrame)P.Parent=p[1].Clone1 end end W=Instance.new("\087\101\108\100")W.Part0=p[1].Clone1 W.Part1=Handle W.C0=p[1].Original.CFrame:toObjectSpace(Handle.CFrame)W.Parent=p[1].Clone1 TweenJoint(LWeld,ArmC0[1],CF(0,.61,0)*CFANG(RAD(70),0,0),Linear,.5*P)TweenJoint(RWeld,ArmC0[2],CF(.4,.09,-0.21)*CFANG(RAD(20),RAD(3),0),Linear,.35*P)TweenJoint(Grip,Grip.C0,CFANG(0,RAD(10),0),Linear,.5*P)wait(.3*P)end;function()TweenJoint(RWeld,ArmC0[2],CF(.4,-0.01,-0.31)*CFANG(RAD(-22),RAD(3),0),Sine,.3*P)wait(.2*P)end;function()W:Destroy()p[1].Clone1.Velocity=Handle.Velocity+Handle.CFrame:vectorToWorldSpace(VEC3(0,-5,0))*20 spawn(function()while p[1].Clone1.Velocity.magnitude>.1 do wait()end for P,p in pairs(p)do p.Clone1.Anchored=true p.Clone1:BreakJoints()end end)for P,W in pairs(p)do W.Clone2.Parent=Gun_Ignore if P~=1 then local P=Instance.new("\087\101\108\100")P.Part0=p[1].Clone2 P.Part1=W.Clone2 P.C0=p[1].Clone2.CFrame:toObjectSpace(W.Clone2.CFrame)P.Parent=p[1].Clone2 end end u=Instance.new("\087\101\108\100")u.Part0=FakeLArm u.Part1=p[1].Clone2 u.C0=CF(0,-1,0)*CFANG(RAD(-90),0,0)u.Parent=FakeLArm wait(.1)end;function()local W=(LWeld.Part0.CFrame*ArmC0[1])*(CF(.3,1.9,-0.31)*CFANG(RAD(-20),RAD(30),RAD(-60))):inverse()local Y=(RWeld.Part0.CFrame*ArmC0[2])*(CF(.4,-0.1,-0.21)*CFANG(RAD(-20),RAD(5),RAD(10))):inverse()local f=FakeRArm.CFrame:toObjectSpace(Grip.Part0.CFrame*Grip.C0)local h=Handle.CFrame:toObjectSpace(p[1].Original.CFrame)local O=W:toObjectSpace((Y*f)*h)TweenJoint(LWeld,ArmC0[1],CF(.6,1.8,-0.3)*CFANG(RAD(-12),RAD(40),RAD(-60)),Sine,.6*P)TweenJoint(RWeld,ArmC0[2],CF(.6,-0.1,-0.5)*CFANG(RAD(-20),RAD(15),RAD(10)),Sine,.6*P)TweenJoint(Grip,Grip.C0,CF(),Sine,.6*P)TweenJoint(u,O,CF(),Sine,.6*P)wait(.8*P)end,function()for P,p in pairs(p)do p.Original.Transparency=0 p.Clone2:Destroy()end TweenJoint(LWeld,ArmC0[1],S.ArmC1_UnAimed.Left,Sine,.5*P)TweenJoint(RWeld,ArmC0[2],S.ArmC1_UnAimed.Right,Sine,.5*P)TweenJoint(Grip,Grip.C0,CFANG(0,RAD(20),0),Sine,.5*P)wait(.5*P)end}for P,p in pairs(Y)do if BreakReload then break end p()end if W then W:Destroy()end if u then u:Destroy()end for P,p in pairs(p)do p.Clone1:Destroy()p.Clone2:Destroy()end end function Reload()Running=false if Ammo.Value<ClipSize.Value and(not Reloading and StoredAmmo.Value>0)then AmmoInClip=AmmoInClip==0 and Ammo.Value or AmmoInClip Ammo.Value=0 Reloading=true if Aimed then UnAimGun(S.ReloadAnimation)end Gui_Clone.CrossHair.Reload.Visible=true if Handle:FindFirstChild("\082\101\108\111\097\100\083\111\117\110\100")then Handle.ReloadSound:Play()end if S.ReloadAnimation then wait()ReloadAnim()else local P=tick()while true do if BreakReload then break end if tick()-P>=S.ReloadTime then break end RS:wait()end end if not BreakReload then if StoredAmmo.Value>=ClipSize.Value then Ammo.Value=ClipSize.Value if AmmoInClip>0 then StoredAmmo.Value=StoredAmmo.Value-(ClipSize.Value-AmmoInClip)else StoredAmmo.Value=StoredAmmo.Value-ClipSize.Value end elseif StoredAmmo.Value<ClipSize.Value and StoredAmmo.Value>0 then Ammo.Value=StoredAmmo.Value StoredAmmo.Value=0 end end BreakReload=false Reloading=false if Selected then AmmoInClip=0 Gui_Clone.CrossHair.Reload.Visible=false end end end
--------------------[ RELOAD FUNCTIONS ]----------------------------------------------

function ReloadAnim()
	TweenJoint(LWeld2, CF(), CF(), Sine, 0.15)
	TweenJoint(RWeld2, CF(), CF(), Sine, 0.15)
	local Speed = S.ReloadTime / 2
	local Mag_Parts = {}

	for _, Obj in pairs(Gun:GetChildren()) do
		if Obj.Name == "Mag" and Obj:IsA("BasePart") then
			INSERT(Mag_Parts, { Original = Obj, Clone1 = Obj:Clone(), Clone2 = Obj:Clone() })
		end
	end

	local W1 = nil
	local W2 = nil

	local SequenceTable = {

		function()
			for Index, Mag in pairs(Mag_Parts) do
				Mag.Original.Transparency = 1
				Mag.Clone1.Parent = Gun_Ignore
				Mag.Clone1.CanCollide = true

				if Index ~= 1 then
					local W = Instance.new("Weld")
					W.Part0 = Mag_Parts[1].Clone1
					W.Part1 = Mag.Clone1
					W.C0 = Mag_Parts[1].Clone1.CFrame:toObjectSpace(Mag.Clone1.CFrame)
					W.Parent = Mag_Parts[1].Clone1
				end
			end

			W1 = Instance.new("Weld")
			W1.Part0 = Mag_Parts[1].Clone1
			W1.Part1 = Handle
			W1.C0 = Mag_Parts[1].Original.CFrame:toObjectSpace(Handle.CFrame)
			W1.Parent = Mag_Parts[1].Clone1

			TweenJoint(LWeld, ArmC0[1], CF(0, 0.61, 0) * CFANG(RAD(70), 0, 0), Linear, 0.5 * Speed)
			TweenJoint(RWeld, ArmC0[2], CF(0.4, 0.09, -0.21) * CFANG(RAD(20), RAD(3), 0), Linear, 0.35 * Speed)
			TweenJoint(Grip, Grip.C0, CFANG(0, RAD(10), 0), Linear, 0.5 * Speed)
			wait(0.3 * Speed)
		end,

		function()
			TweenJoint(RWeld, ArmC0[2], CF(0.4, -0.01, -0.31) * CFANG(RAD(-22), RAD(3), 0), Sine, 0.3 * Speed)
			wait(0.2 * Speed)
		end,

		function()
			W1:Destroy()
			Mag_Parts[1].Clone1.Velocity = Handle.Velocity + Handle.CFrame:vectorToWorldSpace(VEC3(0, -5, 0)) * 20
			spawn(function()
				while Mag_Parts[1].Clone1.Velocity.magnitude > 0.1 do
					wait()
				end
				for _, Mag in pairs(Mag_Parts) do
					Mag.Clone1.Anchored = true
					Mag.Clone1:BreakJoints()
				end
			end)

			for Index, Mag in pairs(Mag_Parts) do
				Mag.Clone2.Parent = Gun_Ignore

				if Index ~= 1 then
					local W = Instance.new("Weld")
					W.Part0 = Mag_Parts[1].Clone2
					W.Part1 = Mag.Clone2
					W.C0 = Mag_Parts[1].Clone2.CFrame:toObjectSpace(Mag.Clone2.CFrame)
					W.Parent = Mag_Parts[1].Clone2
				end
			end

			W2 = Instance.new("Weld")
			W2.Part0 = FakeLArm
			W2.Part1 = Mag_Parts[1].Clone2
			W2.C0 = CF(0, -1, 0) * CFANG(RAD(-90), 0, 0)
			W2.Parent = FakeLArm
			wait(0.1)
		end,

		function()
			local FakeLArmCF = LWeld.Part0.CFrame
				* ArmC0[1]
				* (CF(0.3, 1.9, -0.31) * CFANG(RAD(-20), RAD(30), RAD(-60))):inverse()
			local FakeRArmCF = RWeld.Part0.CFrame
				* ArmC0[2]
				* (CF(0.4, -0.1, -0.21) * CFANG(RAD(-20), RAD(5), RAD(10))):inverse()
			local HandleCF = FakeRArm.CFrame:toObjectSpace(Grip.Part0.CFrame * Grip.C0)
			local Mag_Original_CF = Handle.CFrame:toObjectSpace(Mag_Parts[1].Original.CFrame)
			local MagC0 = FakeLArmCF:toObjectSpace(FakeRArmCF * HandleCF * Mag_Original_CF)

			TweenJoint(LWeld, ArmC0[1], CF(0.6, 1.8, -0.3) * CFANG(RAD(-12), RAD(40), RAD(-60)), Sine, 0.6 * Speed)
			TweenJoint(RWeld, ArmC0[2], CF(0.6, -0.1, -0.5) * CFANG(RAD(-20), RAD(15), RAD(10)), Sine, 0.6 * Speed)
			TweenJoint(Grip, Grip.C0, CF(), Sine, 0.6 * Speed)
			TweenJoint(W2, MagC0, CF(), Sine, 0.6 * Speed)
			wait(0.8 * Speed)
		end,

		function()
			for _, Mag in pairs(Mag_Parts) do
				Mag.Original.Transparency = 0
				Mag.Clone2:Destroy()
			end

			TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Sine, 0.5 * Speed)
			TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Sine, 0.5 * Speed)
			TweenJoint(Grip, Grip.C0, CFANG(0, RAD(20), 0), Sine, 0.5 * Speed)
			wait(0.5 * Speed)
		end,
	}

	for _, ReloadFunction in pairs(SequenceTable) do
		if BreakReload then
			break
		end
		ReloadFunction()
	end

	if W1 then
		W1:Destroy()
	end
	if W2 then
		W2:Destroy()
	end
	for _, Mag in pairs(Mag_Parts) do
		Mag.Clone1:Destroy()
		Mag.Clone2:Destroy()
	end
end

function Reload()
	Running = false
	if Ammo.Value < ClipSize.Value and not Reloading and StoredAmmo.Value > 0 then
		AmmoInClip = (AmmoInClip == 0 and Ammo.Value or AmmoInClip)
		Ammo.Value = 0
		Reloading = true
		if Aimed then
			UnAimGun(S.ReloadAnimation)
		end
		Gui_Clone.CrossHair.Reload.Visible = true
		if Handle:FindFirstChild("ReloadSound") then
			Handle.ReloadSound:Play()
		end
		if S.ReloadAnimation then
			wait()
			ReloadAnim()
		else
			local StartReload = tick()
			while true do
				if BreakReload then
					break
				end
				if (tick() - StartReload) >= S.ReloadTime then
					break
				end
				RS:wait()
			end
		end
		if not BreakReload then
			if StoredAmmo.Value >= ClipSize.Value then
				Ammo.Value = ClipSize.Value
				if AmmoInClip > 0 then
					StoredAmmo.Value = StoredAmmo.Value - (ClipSize.Value - AmmoInClip)
				else
					StoredAmmo.Value = StoredAmmo.Value - ClipSize.Value
				end
			elseif StoredAmmo.Value < ClipSize.Value and StoredAmmo.Value > 0 then
				Ammo.Value = StoredAmmo.Value
				StoredAmmo.Value = 0
			end
		end
		BreakReload = false
		Reloading = false
		if Selected then
			AmmoInClip = 0
			Gui_Clone.CrossHair.Reload.Visible = false
		end
	end
end
