How to make that when a player types something in a textlabel it goes to a random person in a team

I would like to know how to make that when a player types something in a text label it goes to a random person in a team

My Suggestion here is get the Teammate of that player in a table 1st using

local Teammates = {}  --making table
for i, v in pairs(LocationOfTheTeam:GetChildren()) do
if v ~= ThePlayerWhoSendTheText then
table.insert(Teammates, v) --inserting all of the teammate
end
end

then.after he types in something in text label and that player hit enter before sending that text do

math.random(Teammates)--this is an example won't work properly

where should this go and i want it that when a player types something in a text box and press submit it goes to a team but a random player in it

-The GetChildren Script should be inside a script

-then a local script from a textlabel thats connected to the local player

-Then you can use a
OnServerEvent to send it to other player after getting the arguments from the local script