How to retrieve all users in a TextChannel?

Im currently working on a Custom Text Chat system, i done alot of progress but hit a roadblock. I looked all over the documentation for some way to retrieve all the users in a TextChannel. I even tried iterating over the TextSources that are Descendants of the TextChannel but that didnt really work for some specific edge cases like users having same DisplayNames and just overall getting players from names is not the safest option.

So what is the best way to get all users within a TextChannel (On server)?


For anyone wondering why i need it, I need to be able to only show chat bubbles to specific clients when chatting in Team Chat / Whispers.

Perhaps use a for loop (forgive me if this code is wrong I haven’t done a for loop in a bit)

for children, i in pairs(--text channel:GetChildren()) do
     --children is a variable that carries all the children this I know for sure.
end

--IM NOT SURE!! but you may also be able to do this

local children = for children, I in pairs(textchannelhere:GetChildren()) do return children end

I mention in the post i already tried this, I found a solution already. Apparently TextSource has a UserId property that keeps the UserId of the user that the text source represents.

local Recipients = TextChannel:GetDescendants()

for _,TextSource in pairs(Recipients) do
	local Recipient = Players:GetPlayerByUserId(TextSource.UserId)
	ChatReplicationRemote:FireClient(Recipient,FilteredMessage)	
end