Team script not working for some odd reason?

So, I am working on a team script for someone, and it’s not working as I planned to.
Explanation: https://gyazo.com/66d8113832b958e52a4fdcef72c700c2
So, in the GUI the text color should be the color of the team, which is only achieved by the name of the group and the client found that. But in the server, it somehow didn’t find it?

Client Code:

local gids = {
        [7813751] = [[//Security Containment Procedures Foundation\\\\]],
        [8667044] = [[///Scientific Department\\\]],
        [8666926] = [[///Security Department\\\]],
        [8670890]=[[//SCPF// InternaI Security Department]],
        [8864196]=[[///Department of External Affairs\\\]],
        [8717740]=[[//Tactical Security Detachment\\]],
        [8718347]=[[///Medical Department\\\]],
        [8718214]=[[///Ethics Committee\\\]],
        [8718251]=[[///Intelligence Agency\\\]],
        [8717163]=[[///Mobile Task Force\\\]],
        
}
local ex = script.example
ex.Parent = nil
local p = game:GetService('Players')
local player = p.LocalPlayer
local ts = game:GetService('TweenService')
local O = TweenInfo.new(.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local I = TweenInfo.new(.2,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0)
local tcg = script.Parent.tcg
for i,n in next,gids do
        if player:IsInGroup(i) then
                local c = ex:Clone()
                c.Parent = tcg.l
                c.Name = i
                c.Text = n
                local tea = game:GetService('Teams')
                if tea:FindFirstChild(n) then
                        c.TextColor3 = tea[n].TeamColor.Color
                end
                c.MouseButton1Click:connect(function()
                        local rs = game:GetService('ReplicatedStorage')
                        local req = rs:FindFirstChild('tc')
                        if req then
                                req:FireServer(c.Name)
                                CLOSE()
                        end
                end)
        end
end
local uis = game:GetService('UserInputService')
local open = false
function OPEN()
        tcg.Visible = true
        local prop = {
                BackgroundTransparency = 0
        }
        local p2 = {
                TextTransparency = 0
        }
        local b = ts:Create(tcg,I,prop)
        b:Play()
        local d = ts:Create(tcg.TextLabel,I,p2)
        d:Play()
        open = true
end
function CLOSE()
        local prop = {
                BackgroundTransparency = 1
        }
        local p2 = {
                TextTransparency = 1
        }
        local b = ts:Create(tcg,I,prop)
        b:Play()
        local d = ts:Create(tcg.TextLabel,I,p2)
        d:Play()
        open = false
        wait(.2)
        tcg.Visible = false
end
local req = {
        [Enum.KeyCode.F] = {
                limit=1,
                func=function()
                        if open == false then
                                OPEN()
                        else
                                CLOSE()
                        end
                        
                end,
                pressed=0
        }
}
uis.InputBegan:connect(function(o,gm)
        if not gm then
                if req[o.KeyCode] then
                        local i = req[o.KeyCode].limit
                        local f = req[o.KeyCode].func
                        local p = req[o.KeyCode].pressed
                        if  p >= i then
                                f()
                        else
                                req[o.KeyCode].pressed = req[o.KeyCode].pressed + 1
                                spawn(function()
                                        wait(.4)
                                        req[o.KeyCode].pressed = 0
                                end)
                                
                        end
                end
        end
end)

Server code:

local cache = {}
local c = {
        [7813751] = [[//Security Containment Procedures Foundation\\\\]],
        [8667044] = [[///Scientific Department\\\]],
        [8666926] = [[///Security Department\\\]],
        [8670890]=[[//SCPF// InternaI Security Department]],
        [8864196]=[[///Department of External Affairs\\\]],
        [8717740]=[[//Tactical Security Detachment\\]],
        [8718347]=[[///Medical Department\\\]],
        [8718214]=[[///Ethics Committee\\\]],
        [8718251]=[[///Intelligence Agency\\\]],
        [8717163]=[[///Mobile Task Force\\\]],

}
game.ReplicatedStorage.tc.OnServerEvent:Connect(function(player,requesting)
        if not requesting then player:Kick(' - Exploiting. -') end
        if not typeof(requesting) == 'number' then player:Kick(' - Exploiting. -') end
        if player:IsInGroup(requesting) then
                
                local name = c[requesting]
                local ts = game:GetService('Teams')
                if ts:FindFirstChild(name) then
                        local t=game.Teams[name]
                        local rank = player:GetRankInGroup(requesting)
                        if rank ~= 0 then
                                player.Team = t
                                player:LoadCharacter()
                        end
                else
                        print('Team not found.')
                end
        end
       
end)

Are you be able to send the project file? Then I could test it out for myself.

ProjectFile.rbxl (31.5 KB)

I’m sorry, but how do you activate the GUI?

Nevermind, I figured it out, I had to press the F key.

The previous statement was incorrect

I’m gonna guess this is a issue with roblox’s sandbox. Because this shouldn’t error at all since they are using the same method, however it does even though the numbers match.

I found the solution, writing it down now. Don’t close the post yet.

Alright, I found the bug, first of all I would recommend changing the indentation of the code, since it’s a bit hard to read. Anyways, at those lines you made it into a comment, while it should be a string.

Comment:
image

String:

You also didn’t spell the team names like in the table.

Table
image

Actual Team
image

So make sure that the team names matches all of the strings in the table and that it are strings and no comments.

Also, you don’t have to write the group name’s down in the table, you can use this instead:
https://developer.roblox.com/en-us/api-reference/function/GroupService/GetGroupInfoAsync

So make sure that every role has a team assigned to it, what it hasn’t yet.

local gids = {
	[7813751] = "Foundation Personnel",
	[8667044] = "Scientific Department",
	[8666926] = "Security Department",
	[8670890] = "SCPF // InternaI Security Department",
	[8864196] = "Department of External Affairs",
	[8717740] = "Tactical Security Detachment",
	[8718347] = "Medical Department",
	[8718214] = "Ethics Committee",
	[8718251] = "Intelligence Agency",
	[8717163] = "Mobile Task Force",

}

local ex = script.example
ex.Parent = script.Parent:WaitForChild("tcg"):WaitForChild("l")

local p = game:GetService('Players')
local player = p.LocalPlayer
local ts = game:GetService('TweenService')
local O = TweenInfo.new(.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local I = TweenInfo.new(.2,Enum.EasingStyle.Sine,Enum.EasingDirection.In,0,false,0)
local tcg = script.Parent.tcg
for i,n in next,gids do
        if player:IsInGroup(i) then
                local c = ex:Clone()
                c.Parent = tcg.l
                c.Name = i
                c.Text = n
		local tea = game:GetService('Teams')
		print("test")
		if tea:FindFirstChild(n) then
			print("test1")
                        c.TextColor3 = tea[n].TeamColor.Color
                end
                c.MouseButton1Click:connect(function()
                        local rs = game:GetService('ReplicatedStorage')
                        local req = rs:FindFirstChild('tc')
                        if req then
                                req:FireServer(c.Name)
                                CLOSE()
                        end
                end)
        end
end
local uis = game:GetService('UserInputService')
local open = false
function OPEN()
        tcg.Visible = true
        local prop = {
                BackgroundTransparency = 0
        }
        local p2 = {
                TextTransparency = 0
        }
        local b = ts:Create(tcg,I,prop)
        b:Play()
        local d = ts:Create(tcg.TextLabel,I,p2)
        d:Play()
        open = true
end
function CLOSE()
        local prop = {
                BackgroundTransparency = 1
        }
        local p2 = {
                TextTransparency = 1
        }
        local b = ts:Create(tcg,I,prop)
        b:Play()
        local d = ts:Create(tcg.TextLabel,I,p2)
        d:Play()
        open = false
        wait(.2)
        tcg.Visible = false
end
local req = {
        [Enum.KeyCode.F] = {
                limit=1,
                func=function()
                        if open == false then
                                OPEN()
                        else
                                CLOSE()
                        end
                        
                end,
                pressed=0
        }
}
uis.InputBegan:connect(function(o,gm)
        if not gm then
                if req[o.KeyCode] then
                        local i = req[o.KeyCode].limit
                        local f = req[o.KeyCode].func
                        local p = req[o.KeyCode].pressed
                        if  p >= i then
                                f()
                        else
                                req[o.KeyCode].pressed = req[o.KeyCode].pressed + 1
                                spawn(function()
                                        wait(.4)
                                        req[o.KeyCode].pressed = 0
                                end)
                                
                        end
                end
        end
end)

Good luck with your project!

You are wrong.
Those aren’t comments, if it was, the whole script would error.
The teams names are experimental, they’re not supposed to be pin-point accurate.

Oh, alright, I see now, anyway, I tried the script with the “” to make it a string and that worked fine.