Team Error (Need Help)

local main = 13810625
local homecommand = 13067316
local ets = 14034293
local rmp = 13832006
local otc = 14011828
local gfd = 12950379
local rifle = 14037796
local fgr = 14077062
local rtr = 14077080
local uksf = 13809488
local sas = 14084473
local srr = 14084479
local ab = 13844737

local Teams = game:GetService("Teams")

game.Players.PlayerAdded:Connect(function(player)
	player.leaderstats.Reg.Value = "BA"
	if player:IsInGroup(main) then
		if player:GetRankInGroup(main) >= 25 then
			player.Team = Teams["General Staff"]
		else
			if player:IsInGroup(gfd) then
				if player:GetRankInGroup(gfd) >= 8 then
					player.leaderstats.Reg.Value = "1GFD"
				else
					if player:IsInGroup(rifle) then
						player.leaderstats.Reg.Value = "1RIFLES"
					elseif player:IsInGroup(fgr) then
						player.leaderstats.Reg.Value = "4GR"
					elseif player:IsInGroup(rtr) then
						player.leaderstats.Reg.Value = "RTR"
					end
				end
				player.Team = Teams["1st Ground Forces Division"]
			elseif player:IsInGroup(homecommand) then
				if player:IsInGroup(ets) then
					player.leaderstats.Reg.Value = "ETS"
					player.Team = Teams["Training Services"]
				elseif player:IsInGroup(rmp) then
					player.leaderstats.Reg.Value = "RMP"
					player.Team = Teams["Royal Military Police"]
				elseif player:IsInGroup(otc) then
					player.leaderstats.Reg.Value = "OTC"
					player.Team = Teams["Training Services"]
				end
			elseif player:IsInGroup(uksf) then
				if player:GetRoleInGroup(uksf) == "Commanding General" then
					player.leaderstats.Reg.Value = "UKSF"
				else
					if player:IsInGroup(sas) then
						player.leaderstats.Reg.Value = "SAS"
					elseif player:IsInGroup(srr) then
						player.leaderstats.Reg.Value = "SRR"
					end
				end
				player.Team = Teams["Special Forces"]
			elseif player:IsInGroup(ab) then
				player.leaderstats.Reg.Value = "16AB"
				player.Team = Teams["16th Assault Brigade"]
			else
				if player:GetRankInGroup(main) == 1 then
					player.Team = Teams["Basic Military Training"]
				elseif player:GetRankInGroup(main) > 1 and player:GetRankInGroup(main) <= 11 then
					player.Team = Teams["Regimental Recruit"]
				elseif player:GetRankInGroup(main) > 11 and player:GetRankInGroup(main) < 25 then
					player.Team = Teams["Officer"]
				end
			end
		end
	else
		player.Team = Teams["Civilian"]
		player.leaderstats.Reg.Value = "CIV"
	end
	wait(1)
	player:LoadCharacter()
end)

Does anyone know why this team script doesn’t work?

What’s the error that you get?

what the heck are those number variables

Those are group ID’s i believe.

ohhh i see, thx for explaining that, i have never seen those things in a script

You’re welcome, if you plop the id’s into a url it works, so the variables are groups

yeah, just tried that after you said those variables were groups

What’s the error that you get? (if there is an error)

There is no error in the output , well only HTTPError, but the think is i have leaderstats based on group but it works