Team By Group Error

So I have two new Server Scripts (Team and Leaderstats)

-- Team
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)

This is the leaderstats

game.Players.PlayerAdded:Connect(function(player)
	
	local lead = Instance.new("Folder", player)
	lead.Name = "leaderstats"
	
	local rank = Instance.new("StringValue", lead)
	rank.Name = "Rank"
	rank.Value = ""
	
	local reg = Instance.new("StringValue", lead)
	reg.Name = "Reg"
	reg.Value = ""
	
	if player:GetRankInGroup(13810625) == 1 then
		rank.Value = "OR-1"
	elseif player:GetRankInGroup(13810625) == 2 then
		rank.Value = "OR-2"
	elseif player:GetRankInGroup(13810625) == 3 then
		rank.Value = "OR-3"
	elseif player:GetRankInGroup(13810625) == 4 then
		rank.Value = "OR-4"
	elseif player:GetRankInGroup(13810625) == 5 then
		rank.Value = "OR-5"
	elseif player:GetRankInGroup(13810625) == 6 then
		rank.Value = "OR-6"
	elseif player:GetRankInGroup(13810625) == 7 then
		rank.Value = "OR-7"
	elseif player:GetRankInGroup(13810625) == 8 then
		rank.Value = "OR-8"
	elseif player:GetRankInGroup(13810625) == 9 then
		rank.Value = "OR-8"
	elseif player:GetRankInGroup(13810625) == 10 then
		rank.Value = "OR-9"
	elseif player:GetRankInGroup(13810625) == 11 then
		rank.Value = "OR-9"
	elseif player:GetRankInGroup(13810625) == 12 then
		rank.Value = "OF-1"
	elseif player:GetRankInGroup(13810625) == 13 then
		rank.Value = "OF-1"
	elseif player:GetRankInGroup(13810625) == 14 then
		rank.Value = "OF-2"
	elseif player:GetRankInGroup(13810625) == 15 then
		rank.Value = "OF-3"
	elseif player:GetRankInGroup(13810625) == 16 then
		rank.Value = "OF-4"
	elseif player:GetRankInGroup(13810625) == 17 then
		rank.Value = "OF-5"
	elseif player:GetRankInGroup(13810625) == 18 then
		rank.Value = "OF-6"
	elseif player:GetRankInGroup(13810625) == 19 then
		rank.Value = "OF-7"
	elseif player:GetRankInGroup(13810625) == 20 then
		rank.Value = "OF-8"
	elseif player:GetRankInGroup(13810625) == 21 then
		rank.Value = "OF-9"
	elseif player:GetRankInGroup(13810625) == 25 then
		rank.Value = "DEV"
	elseif player:GetRankInGroup(13810625) == 120 then
		rank.Value = "ASM"
	elseif player:GetRankInGroup(13810625) == 249 then
		rank.Value = "ACGS"
	elseif player:GetRankInGroup(13810625) == 252 then
		rank.Value = "DCGS"
	elseif player:GetRankInGroup(13810625) == 253 then
		rank.Value = "CGS"
	elseif player:GetRankInGroup(13810625) == 254 then
		rank.Value = "DCDS"
	elseif player:GetRankInGroup(13810625) == 255 then
		rank.Value = "CDS"
	end
end)

the leaderstats Rank Value (OR-1, etc) works but the Reg value which is team, doesn’t work because the player keep moving to Neutral, I already check all there is no Neutral Spawn and also I already turn off AutoAssignable.
Also since there are this two scripts, suddenly one of my local script in a GUI that doesn’t related to this, suddenly doesn’t work, previously without this two server scripts it works.

This is the local script (Material Change)

local player = game.Players.LocalPlayer
local low = false
local Smooth = Enum.Material.SmoothPlastic
local debounce = false
local button = script.Parent
local frame = button.Parent
local TweenService = game:GetService("TweenService")

button.MouseButton1Click:Connect(function()
	if not debounce then
		debounce = true
		if not low then
			local tween = TweenService:Create(frame, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.In, 0, false, 0), {BackgroundColor3 = Color3.fromRGB(0,0,0)})
			tween:Play()
			for i, v in pairs(workspace:GetDescendants()) do
				if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("WedgePart") then
					local oldMat = Instance.new("StringValue", v)
					oldMat.Name = "Original_Mat"
					oldMat.Value = tostring(v.Material)
					v.Material = Smooth
				end
			end
		else
			local tween = TweenService:Create(frame, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.In, 0, false, 0), {BackgroundColor3 = Color3.fromRGB(255,255,255)})
			tween:Play()
			for i, v in pairs(workspace:GetDescendants()) do
				if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("WedgePart") then
					local oldMat1 = v:FindFirstChild("Original_Mat")
					if oldMat1 then
						local countMe = #oldMat1.Value
						local getIt = string.sub(oldMat1.Value, 15, countMe)
						v.Material = getIt
						oldMat1:Destroy()
					end
				end
			end
		end
		low = not low
		wait(1)
		debounce = false
		print("Success")
	end
end)

May someone tell me why this doesn’t work? Why this two server scripts above affect the local script that doesn’t even related. Always give me HttpError too.

When I disable the Team Script, the local script works normal again. Idk why my Team Script gives error, does anyone know how to fix?

1 Like