Value returns as nil when I try to use it as a group id

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 =
local Descendant = descendant:FindFirstChild(“Value”)
local groupId = Descendant.Value
if player:IsInGroup(groupId) then
game.ReplicatedStorage.TeamEvent2:FireServer(player, team, player)

player isn’t defined, or it got shadowed by the parameter of the function. At no point in time does MouseButton1Click return a player to the connected function.

You have to define what player is. If it’s the LocalPlayer, declare it as such