Explanation on how to create a spectator only chat, that also displays the chat of players who are not spectating

Hello so i’ve been trying to figure out exactly how I would go around making this as im trying to make a game with a spectate feature that allows you talk to other people spectating, main issue is that I am not certain on how I’ll be doing this, I’m not too familiar with the chat API, tutorials would be helpful!!!

1 Like

Easiest way is to restrict the spectators to team chat!
Luckily @antonio6643 has made a great explanation!

Hope this helps!

1 Like

alright thank you i’ll read on this

1 Like

I figured it out how to do this with the new TextChatService:

local AllPlayers = game.Players
local TextChatService = game:GetService("TextChatService")
local RBXGeneral = TextChatService:WaitForChild("TextChannels"):WaitForChild("RBXGeneral")

local Spectators = game.Teams.Spectators

-- Is Spectator From UserId
local function IsSpectatorFromUserId(UserId)
	local TargetPlayer = AllPlayers:GetPlayerByUserId(UserId)
	if TargetPlayer and TargetPlayer.Team == Spectators then
		return true
	end
	return false
end
	
-- Set Chat Deliver Callback by Adding our Own Filter to it!
local function SetDeliverCallback(TextChatMessage: TextChatMessage, TargetTextSource: TextSource)
	local SourceIsSpectator = IsSpectatorFromUserId(TextChatMessage.TextSource.UserId)
	local TargetIsSpectator = IsSpectatorFromUserId(TargetTextSource.UserId)
	
	-- If the Target Player is Spectator or Both Players are still Alive/Dead then
	return TargetIsSpectator or (SourceIsSpectator == TargetIsSpectator)
end
RBXGeneral.ShouldDeliverCallback = SetDeliverCallback