function ArmorModule.GetLevel(c)if game.ReplicatedStorage.ARMORS:FindFirstChild(c)~=nil then return(game.ReplicatedStorage.ARMORS:FindFirstChild(c)).Level.Value else return 0 end end function ArmorModule.GetDefense(c)if game.ReplicatedStorage.ARMORS:FindFirstChild(c)~=nil then if game.Workspace.GAME_PROPERTIES.DefenseMode.Value==1 or game.Workspace.GAME_PROPERTIES.DefenseMode.Value==2 then return(game.ReplicatedStorage.ARMORS:FindFirstChild(c)).Defense.Value elseif game.Workspace.GAME_PROPERTIES.DefenseMode.Value==3 then return(game.ReplicatedStorage.ARMORS:FindFirstChild(c)).HPBoost.Value else return 0 end else return 0 end end function ArmorModule.RemoveArmor(c)local r=c:FindFirstChild("\072\117\109\097\110\111\105\100")or c:FindFirstChild("\072\117\109\097\110")if r~=nil then if c:FindFirstChild("\065\114\109\049")~=nil then(c:FindFirstChild("\065\114\109\049")):Remove()end if c:FindFirstChild("\065\114\109\050")~=nil then(c:FindFirstChild("\065\114\109\050")):Remove()end if c:FindFirstChild("\076\101\103\049")~=nil then(c:FindFirstChild("\076\101\103\049")):Remove()end if c:FindFirstChild("\076\101\103\050")~=nil then(c:FindFirstChild("\076\101\103\050")):Remove()end if c:FindFirstChild("\067\104\101\115\116")~=nil then(c:FindFirstChild("\067\104\101\115\116")):Remove()end else return false end end function ArmorModule.EquipArmor(c,r)local p=c:FindFirstChild("\072\117\109\097\110\111\105\100")or c:FindFirstChild("\072\117\109\097\110")if c~=nil then if p~=nil then if c:FindFirstChild("\065\114\109\049")~=nil then(c:FindFirstChild("\065\114\109\049")):Remove()end if c:FindFirstChild("\065\114\109\050")~=nil then(c:FindFirstChild("\065\114\109\050")):Remove()end if c:FindFirstChild("\076\101\103\049")~=nil then(c:FindFirstChild("\076\101\103\049")):Remove()end if c:FindFirstChild("\076\101\103\050")~=nil then(c:FindFirstChild("\076\101\103\050")):Remove()end if c:FindFirstChild("\067\104\101\115\116")~=nil then(c:FindFirstChild("\067\104\101\115\116")):Remove()end end else return false end if p~=nil and c:FindFirstChild("\065\114\109\049")==nil then local p=(game.ReplicatedStorage.ARMORS:FindFirstChild(r)).Arm1:Clone()p.Parent=c local n=p:GetChildren()for r=1,#n,1 do if n[r].ClassName=="\080\097\114\116"then if n[r].Name=="\077\105\100\100\108\101"then n[r].Transparency=1 end local c=Instance.new("\087\101\108\100")c.Part0=p.Middle c.Part1=n[r]local x=CFrame.new(p.Middle.Position)local A=p.Middle.CFrame:inverse()*x local d=n[r].CFrame:inverse()*x c.C0=A c.C1=d c.Parent=p.Middle end local x=Instance.new("\087\101\108\100")x.Part0=c["\076\101\102\116 \065\114\109"]x.Part1=p.Middle x.C0=CFrame.new(0,0,0)x.Parent=x.Part0 end local x=p:GetChildren()for c=1,#x,1 do x[c].Anchored=false x[c].CanCollide=false end end if p~=nil and c:FindFirstChild("\065\114\109\050")==nil then local p=(game.ReplicatedStorage.ARMORS:FindFirstChild(r)).Arm2:Clone()p.Parent=c local n=p:GetChildren()for r=1,#n,1 do if n[r].ClassName=="\080\097\114\116"then if n[r].Name=="\077\105\100\100\108\101"then n[r].Transparency=1 end local c=Instance.new("\087\101\108\100")c.Part0=p.Middle c.Part1=n[r]local x=CFrame.new(p.Middle.Position)local A=p.Middle.CFrame:inverse()*x local d=n[r].CFrame:inverse()*x c.C0=A c.C1=d c.Parent=p.Middle end local x=Instance.new("\087\101\108\100")x.Part0=c["\082\105\103\104\116 \065\114\109"]x.Part1=p.Middle x.C0=CFrame.new(0,0,0)x.Parent=x.Part0 end local x=p:GetChildren()for c=1,#x,1 do x[c].Anchored=false x[c].CanCollide=false end end if p~=nil and c:FindFirstChild("\076\101\103\049")==nil then local p=(game.ReplicatedStorage.ARMORS:FindFirstChild(r)).Leg1:Clone()p.Parent=c local n=p:GetChildren()for r=1,#n,1 do if n[r].ClassName=="\080\097\114\116"then if n[r].Name=="\077\105\100\100\108\101"then n[r].Transparency=1 end local c=Instance.new("\087\101\108\100")c.Part0=p.Middle c.Part1=n[r]local x=CFrame.new(p.Middle.Position)local A=p.Middle.CFrame:inverse()*x local d=n[r].CFrame:inverse()*x c.C0=A c.C1=d c.Parent=p.Middle end local x=Instance.new("\087\101\108\100")x.Part0=c["\076\101\102\116 \076\101\103"]x.Part1=p.Middle x.C0=CFrame.new(0,0,0)x.Parent=x.Part0 end local x=p:GetChildren()for c=1,#x,1 do x[c].Anchored=false x[c].CanCollide=false end end if p~=nil and c:FindFirstChild("\076\101\103\050")==nil then local p=(game.ReplicatedStorage.ARMORS:FindFirstChild(r)).Leg2:Clone()p.Parent=c local n=p:GetChildren()for r=1,#n,1 do if n[r].ClassName=="\080\097\114\116"then if n[r].Name=="\077\105\100\100\108\101"then n[r].Transparency=1 end local c=Instance.new("\087\101\108\100")c.Part0=p.Middle c.Part1=n[r]local x=CFrame.new(p.Middle.Position)local A=p.Middle.CFrame:inverse()*x local d=n[r].CFrame:inverse()*x c.C0=A c.C1=d c.Parent=p.Middle end local x=Instance.new("\087\101\108\100")x.Part0=c["\082\105\103\104\116 \076\101\103"]x.Part1=p.Middle x.C0=CFrame.new(0,0,0)x.Parent=x.Part0 end local x=p:GetChildren()for c=1,#x,1 do x[c].Anchored=false x[c].CanCollide=false end end if p~=nil and c:FindFirstChild("\067\104\101\115\116")==nil then local p=(game.ReplicatedStorage.ARMORS:FindFirstChild(r)).Chest:Clone()p.Parent=c local n=p:GetChildren()for r=1,#n,1 do if n[r].ClassName=="\080\097\114\116"then if n[r].Name=="\077\105\100\100\108\101"then n[r].Transparency=1 end local c=Instance.new("\087\101\108\100")c.Part0=p.Middle c.Part1=n[r]local x=CFrame.new(p.Middle.Position)local A=p.Middle.CFrame:inverse()*x local d=n[r].CFrame:inverse()*x c.C0=A c.C1=d c.Parent=p.Middle end local x=Instance.new("\087\101\108\100")x.Part0=c.Torso x.Part1=p.Middle x.C0=CFrame.new(0,0,0)x.Parent=x.Part0 end local x=p:GetChildren()for c=1,#x,1 do x[c].Anchored=false x[c].CanCollide=false end end end return ArmorModule

function ArmorModule.GetLevel(armor)
	if game.ReplicatedStorage.ARMORS:FindFirstChild(armor) ~= nil then
		return game.ReplicatedStorage.ARMORS:FindFirstChild(armor).Level.Value
	else
		return 0 --If it's not found, returns 0.
	end
end

function ArmorModule.GetDefense(armor)
	if game.ReplicatedStorage.ARMORS:FindFirstChild(armor) ~= nil then
		if game.Workspace.GAME_PROPERTIES.DefenseMode.Value == 1 or game.Workspace.GAME_PROPERTIES.DefenseMode.Value == 2 then
			return game.ReplicatedStorage.ARMORS:FindFirstChild(armor).Defense.Value
		elseif game.Workspace.GAME_PROPERTIES.DefenseMode.Value == 3 then
			return game.ReplicatedStorage.ARMORS:FindFirstChild(armor).HPBoost.Value
		else
			return 0
		end
	else
		return 0 --If the armor is not found, returns 0.
	end
end

function ArmorModule.RemoveArmor(character)
	local humanoid = character:FindFirstChild("Humanoid") or character:FindFirstChild("Human")
	--Remove old armour.
	if humanoid ~= nil then
		if character:FindFirstChild("Arm1") ~= nil then
			character:FindFirstChild("Arm1"):Remove()
		end
		if character:FindFirstChild("Arm2") ~= nil then
			character:FindFirstChild("Arm2"):Remove()
		end	
		if character:FindFirstChild("Leg1") ~= nil then
			character:FindFirstChild("Leg1"):Remove()
		end
		if character:FindFirstChild("Leg2") ~= nil then
			character:FindFirstChild("Leg2"):Remove()
		end	
		if character:FindFirstChild("Chest") ~= nil then
			character:FindFirstChild("Chest"):Remove()
		end	
	else
		return false --Exits the function if it's nil. Prevents the function from breaking.
	end	
end

function ArmorModule.EquipArmor(character, armor)
	local humanoid = character:FindFirstChild("Humanoid") or character:FindFirstChild("Human")
	if character ~= nil then
		--Remove old armour.
		if humanoid ~= nil then
			if character:FindFirstChild("Arm1") ~= nil then
				character:FindFirstChild("Arm1"):Remove()
			end
			if character:FindFirstChild("Arm2") ~= nil then
				character:FindFirstChild("Arm2"):Remove()
			end	
			if character:FindFirstChild("Leg1") ~= nil then
				character:FindFirstChild("Leg1"):Remove()
			end
			if character:FindFirstChild("Leg2") ~= nil then
				character:FindFirstChild("Leg2"):Remove()
			end	
			if character:FindFirstChild("Chest") ~= nil then
				character:FindFirstChild("Chest"):Remove()
			end	
		end
	else
		return false --Exits the function if it's nil. Prevents the function from breaking.
	end
	--Arms
	if humanoid ~= nil and character:FindFirstChild("Arm1") == nil then
		local g = game.ReplicatedStorage.ARMORS:FindFirstChild(armor).Arm1:Clone()
		g.Parent = character
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].ClassName == "Part" then
				if C[i].Name == "Middle" then
					C[i].Transparency = 1
				end
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = character["Left Arm"]
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
		
	end

	if humanoid ~= nil and character:FindFirstChild("Arm2") == nil then
		local g = game.ReplicatedStorage.ARMORS:FindFirstChild(armor).Arm2:Clone()
		g.Parent = character
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].ClassName == "Part" then
				if C[i].Name == "Middle" then
					C[i].Transparency = 1
				end
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = character["Right Arm"]
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
		
	end
	--Legs
	if humanoid ~= nil and character:FindFirstChild("Leg1") == nil then
		local g = game.ReplicatedStorage.ARMORS:FindFirstChild(armor).Leg1:Clone()
		g.Parent = character
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].ClassName == "Part" then
				if C[i].Name == "Middle" then
					C[i].Transparency = 1
				end
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = character["Left Leg"]
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
		
	end

	if humanoid ~= nil and character:FindFirstChild("Leg2") == nil then
		local g = game.ReplicatedStorage.ARMORS:FindFirstChild(armor).Leg2:Clone()
		g.Parent = character
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].ClassName == "Part" then
				if C[i].Name == "Middle" then
					C[i].Transparency = 1
				end
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = character["Right Leg"]
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
		
	end
	--Torso
	if humanoid ~= nil and character:FindFirstChild("Chest") == nil then
		local g = game.ReplicatedStorage.ARMORS:FindFirstChild(armor).Chest:Clone()
		g.Parent = character
		local C = g:GetChildren()
		for i=1, #C do
			if C[i].ClassName == "Part" then
				if C[i].Name == "Middle" then
					C[i].Transparency = 1
				end
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse()*CJ
				local C1 = C[i].CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
				local Y = Instance.new("Weld")
				Y.Part0 = character.Torso
				Y.Part1 = g.Middle
				Y.C0 = CFrame.new(0, 0, 0)
				Y.Parent = Y.Part0
		end

		local h = g:GetChildren()
		for i = 1, # h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
		
	end
end

return ArmorModule
