I’m trying to make a team GUI, which when you click on a button, it changes you to that team, but it is locked to certain groups, and since I have over 30 teams, I didn’t feel like having a 3k line long block of code thats just repeated with different variables, so I decided to make something where the name of the button is the same name as the team, and there is a value that I put in my textbutton with the value of the groupID so that it can automatically put the player in the team without me having the same block of code 30 times. However, when I click on a button, it gives me
“Players.Evanthegr8t1.PlayerGui.MainGameGui.SizingFrame.Team Menu.Airforce.LocalScript:10: attempt to index nil with ‘IsInGroup’”
Here’s my code:
local airforce = script.Parent.Parent.Airforce
local descendants = airforce.Frame:GetDescendants()
for _, descendant in pairs(descendants) do
if descendant:IsA(“TextButton”) then
local team = descendant.name
local Descendant = descendant:FindFirstChild(“Value”)
local groupId = Descendant.Value
descendant.MouseButton1Click:Connect(function(player)
print(groupId)
if player:IsInGroup(groupId) then
game.ReplicatedStorage.TeamEvent2:FireServer(player, team, player)
end
end)
end
end