Explanation below:

print("Begin")
-- Credit: SirAdamFletcher(SAF)
game.Workspace.ChildAdded:connect(function(nc)
if nc:FindFirstChild'Humanoid' then
local np = game.Players:getPlayerFromCharacter(nc)
math.randomseed(tick())
end
local ValueFalse = game.Workspace['Uniforms'].Regimental.Value == false
local TGABTeam = np.TeamColor == BrickColor.new("Bright red")
-- Group IDs
local TGAB = 938940 -- TGAB
local KGL = 2704409 -- King's German Legion
local ROF = 2689795 -- 51st Regiment of Foot
local LDR = 1141913 -- 20th Light Regiment
local CSG = 1046805 -- 1st Battalion Coldstream Guards
local RAR = 946296 -- Royal Artillery Regiment
local RIF = 945877 -- TGAB's 95th Rifles
local HC = 1028334 -- TGAB HC group, for excluding BG+ in a short way
-- IsInGroup
local GroupTGAB = np:IsInGroup(938940)
local GroupKGL = np:IsInGroup(2704409)
local GroupROF = np:IsInGroup(2689795)
local GroupLDR = np:IsInGroup(1141913)
local GroupCSG = np:IsInGroup(938940)
local GroupRAR = np:IsInGroup(946296)
local GroupRIF = np:IsInGroup(945877)
local GroupHC = np:IsInGroup(1028334)
-- GetRankInGroup
local RankTGAB = np:GetRankInGroup(TGAB)
local RankKGL = np:GetRankInGroup(KGL)
local RankROF = np:GetRankInGroup(ROF)
local RankLDR = np:GetRankInGroup(LDR)
local RankCSG = np:GetRankInGroup(CSG)
local RankRAR = np:GetRankInGroup(RAR)
local RankRIF= np:GetRankInGroup(RIF)
local GroupHC = np:GetRankInGroup(HC)
-- TGAB uniforms
local UniTGAB = {
[5] = {189662504,189662826}, -- ranker (Pants, Shirt)
[10] = {189662826,189662504},
[15] = {189662826,189662564},
[20] = {189662826,189662607},
[25] = {189662826,189662662},
[30] = {189662826,189662722},
[33] = {189683554,189662889},
[35] = {189683554,189663112},
[40] = {189683554,189663218},
[45] = {189683554,189663325},
[50] = {189683554,316247247},
[55] = {189683554,316247579},
}
-- KGL uniforms 
local UniKGL = { -- (Pants, Shirt)
[10] = {323562202,323562024},-- Private
[20] = {323562202,324053562},-- Lance Corporal
[30] = {323562202,324053610},-- Corporal
[40] = {323562202,324060942},-- Sergeant
[50] = {323562202,324053799},-- Sergeant Major
--[60] = {163709774,163709657},-- Ensign
--[60] = {163709733,163709597},-- Lieutenant
[110] = {323562202,323562886},-- Captain
[120] = {323562202,323562886},-- Major
[125] = {323562202,323562886},-- Commissioner
[130] = {323562202,323562886},-- Lieutenant Colonel
[240] = {323562202,323562886},-- Colonel
[250] = {323562202,323562886},-- Colonel in Chief
[253] = {323562202,323562886},-- Overseer
[254] = {323562202,323562886}-- King]]
}
 
-- ROF uniforms, need rank IDs
local UniROF = {-- (Pants, Shirt)
[0] = {322497225,322496193}, -- Ranker 1st Battalion
[0] = {322497225,322496467}, -- XO 1st Battalion
[0] = {322497225,322496467}, -- CO 1st Battalion
[0] = {322497225,322496193}, -- Ranker 2nd Battalion
[0] = {322497225,322496467}, -- XO 2nd Battalion
[0] = {322497225,322496467}, -- CO 2nd Battalion
[0] = {322497225,322496539}, -- Honourary Musician
[0] = {322497225,322496539}, -- Overseers
[0] = {322497225,322496539}, -- Colonel of the Regiment
[0] = {322497225,322496539}, -- Colonel-In-Chief
}
-- LDR uniforms     
 local UniLDR = {-- (Pants, Shirt)
[50] = {319572335,319572150}, -- Trooper
[100] = {319572335,319572089},-- Lance Corporal
[150] = {319572335,319571993},-- Lance Corporal of The Horse
[180] = {319572335,319571960},-- Corporal of The Horse
[181] = {319572335,319571901},-- Staff Corporal 
[182] = {319572335,319571874},-- Regimental Corporal Major
[185] = {319572292,319571815},-- Cornet
[190] = {319572292,319571815},-- Lieutenant
[200] = {319572292,319571784},-- Captain
[220] = {319572292,319571743},-- Major
[235] = {319572292,319571690},-- Commissioner 
[240] = {319572292,319571624},-- Lieutenant Colonel
[253] = {319572292,319571523},-- Colonel
[254] = {319572292,319571815},-- Colonel-In-Chief
[255] = {319572292,319571815},-- Head of Army
}
-- CSG uniforms     
local UniCSG = { -- (Pants, Shirt)
[10] = {196438244,196438166},-- Guardsman
[20] = {196438244,196438166},-- Lance Corporal
[30] = {196438244,196438185},-- Corporal
[40] = {196438244,196438185},-- Sergeant
[50] = {196438244,196438185},-- Staff Sergeant
[60] = {196438244,196438225},-- Ensign
[60] = {196438244,196438225},-- Lieutenant
[110] = {196438244,196438225},-- Captain
[120] = {196438244,196438225},-- Major
[125] = {196438244,196438225},-- Commissioner
[130] = {196438244,196438225},-- Lieutenant Colonel
[240] = {196438244,196438225},-- Colonel
[250] = {196438244,196438225},-- High Commander Overseer
[253] = {196438244,196438225},-- Colonel in Chief
}
-- RAR uniforms     
local UniRAR = {-- (Pants, Shirt)
[4] = {261701567,261701368},-- Third Battery Crew
[5] = {261701567,261701158},-- Third Battery Officers
[6] = {261701567,261701158},-- Third Battery Commander
[9] = {261701567,261701368},-- Second Battery Crew
[10] = {261701567,261701158},-- Second Battery Officers
[11] = {261701567,261701158},-- Second Battery Commander
[13] = {261701567,261701368},-- First Battery Crew
[14] = {261701567,261701158},-- First Battery Officers
[15] = {261701567,261701158},-- First Battery Commander
[49] = {261701567,261701158},-- [HC] Artillery Staff Officers
[50] = {261701567,261701158},-- [HC] Senior Staff Officers
[254] = {261701567,261701158},-- [HC] Head of the Regiment
[255] = {261701567,261701158},-- Head of Army
}
-- RIF uniforms     
local UniRIF = {-- (Pants, Shirt)
[5] = {163177473,163847406},--Musicians
[30] = {163177473,163847406},--Rifleman
[40] = {163177473,163177527},--Corporal
[50] = {163177473,163847489},--Sergeant <LR/>
[70] = {163177473,163847532},--Colour Sergeant
[80] = {163177473,163847711},--Officer in Training
[90] = {163177473,163847711},--Advanced Rifleman <MR/>
[105] = {163177473,163847818},--Lieutenant
[110] = {163177473,163847818},--Elite Rifleman <HR/>
[122] = {163177473,163847949},--Colonel
[125] = {163177473,163847949},--Darth Giraffe
[251] = {163177473,163847949},--Overseers
[252] = {163177473,163847949},--Chosen Men
[254] = {163177473,163847949},--Minister of Regimentbubbles
[255] = {163177473,163847949},--El Senor Kibblez ~95th Dictator 2015
}
function give(char,pants,shirt)
-- ypcall(function()
repeat wait() until char:FindFirstChild("Torso") and char:FindFirstChild("Humanoid")
wait(2)
for _,v in pairs(char:children()) do if v:IsA("Shirt") or v:IsA("Pants") then v:destroy() end end
local p = Instance.new("Pants",char)
local s = Instance.new("Shirt",char)
p.PantsTemplate = "http://www.roblox.com/asset/?id="..pants-1
s.ShirtTemplate = "http://www.roblox.com/asset/?id="..shirt-1
for _,v in pairs(char:children()) do if v:IsA("CharacterMesh") then v:Destroy() end end
--end)
end 
 
--np.CharacterAdded:connect(function(nc)--
if TGABTeam then --[[game.Workspace['KGL Uniforms'].KGL.Value == true and np.Name ~= "Lightrater" and
        np.Name ~= "alertcoderf" and np.Name ~= "sy1892" and np.Name ~= "LordRichardFletcher" and np.Name ~= "SirAdamFletcher"
        then --]]
------------------
-- In only TGAB? Give regular uniform
if GroupTGAB then
	if GroupKGL or GroupROF or GroupLDR or GroupCSG or GroupRAR or GroupRIF or GroupHC then return end-- HC are excluded
	else  
for _,v in pairs(UniTGAB) do
if RankTGAB == _ then
print("Give TGAB uniform")
give(np.Character,v[1],v[2])
break
end
end
end
-- In more than one regiment? Give them regular uniform
if TGABTeam then
	if GroupKGL and GroupROF or GroupKGL and GroupLDR or GroupKGL and GroupCSG or GroupKGL and GroupRAR or GroupKGL and GroupRIF or GroupROF and GroupLDR or GroupROF and GroupCSG or GroupROF and GroupRAR or GroupROF and GroupRIF or GroupLDR and GroupCSG or GroupLDR and GroupRAR or GroupLDR and GroupRIF or GroupCSG and GroupRAR or GroupCSG and GroupRIF or GroupRAR and GroupRIF then return else end
else
for _,v in pairs(UniTGAB) do
if RankTGAB == _ then
give(np.Character,v[1],v[2])
break
end
end
end
-- In KGL:
if TGABTeam then
	if GroupHC then return end
	else
	if GroupKGL then return else return end
for r,v in pairs(UniKGL) do
if RankKGL == r then
give(np.Character,v[1],v[2])
break
end
end
end
-- In ROF:
if TGABTeam then
	if GroupHC then return end
	else
	if GroupROF then return else return end
for r,v in pairs(UniROF) do
if RankROF == r then
give(np.Character,v[1],v[2])
break
end
end
end
-- In LDR:
if TGABTeam then
	if GroupHC then return end
	else
	if GroupLDR then return else return end
for r,v in pairs(UniLDR) do
if RankLDR == r then
give(np.Character,v[1],v[2])
break
end
end
end
-- In CSG:
if TGABTeam then
	if GroupHC then return end
	else
	if GroupCSG then return else return end
for r,v in pairs(UniCSG) do
if RankCSG == r then
give(np.Character,v[1],v[2])
break
end
end
end
-- In RAR:
if TGABTeam then
	if GroupHC then return end
	else
	if GroupRAR then return else return end
for r,v in pairs(UniRAR) do
if RankRAR == r then
give(np.Character,v[1],v[2])
break
end
end
end
-- In RIF:
if TGABTeam then
	if GroupHC then return end
	else
	if GroupRIF then return else return end
for r,v in pairs(UniRIF) do
if RankRIF == r then
give(np.Character,v[1],v[2])
break
end
end
end
------------------
end)
-----------------
local TGAB = 938940 -- TGAB
local LoadCommand = ":regimental off"
local RemoveCommand = ":regimental on" 
local Value = game.Workspace['Uniforms'].Regimental.Value

function CheckAdmin(Player)
	local RankTGAB = Player:GetRankInGroup(TGAB)
	local loser = Player.Name == "gameman625"
	local v = false
	if RankTGAB>= 33 or loser then
		v = true
	end
	return v
end

game.Players.PlayerAdded:connect(function(Player)
	Player.Chatted:connect(function(Message)
		if CheckAdmin(Player) and string.lower(string.sub(Message,1,string.len(LoadCommand))) == string.lower(LoadCommand) then
			Value = false
		print("game.Workspace['Uniforms'].Regimental.Value = false")
		elseif CheckAdmin(Player) and string.lower(string.sub(Message,1,string.len(RemoveCommand))) == string.lower(RemoveCommand) then
			Value = true
		print("game.Workspace['Uniforms'].Regimental.Value = true")
		end
	end)
end)

5 comments

0

Ran out of characters... Explanation: When on the bright red team, and upon spawn, a player automatically spawns with a uniform of their rank in a specific group. There is a main group, and 7 children group. If not in the children group, they get the main uniform. If in more than one children group, they get the main uniform. Otherwise, they get the children group's specific uniform. I cannot find

0

Some people might but you cannot expect someone to look through a 300 line code, which isn't even finished

0

You're going to have to find the error through Dev Console or Output and narrow down the script to that function. We can not sit through 300 lines of code to find an error.

0

Then I will hope that someone might come along who is interested. Also, it is finished.

0

Question: What are the proper amount and order of ends for lines 266 and thereafter?