Muting a team from a client sided script

how do i mute a whole team from a local script like an option true/false for example if there is a team named Fans and you got the option set to true you shouldnt see Fans messages until you turn it back on so you can see new ones

basically its like hiding Fans messages so a player cant see them (client sided)

You can insert a localscript in starterplayerscripts

local tcs = game:GetService("TextChatService")
local muted = false
tcs.OnIncomingMessage = function(message)
    if not muted or player.Team.Name ~= "Fans" then return end
    local prop = Instance.new("TextChatMessageProperties")
    prop.PrefixText = ""
    prop.Text = ""
    return prop
end

set muted to change the outcome

it says player is uknown global did you forgot to put smth?

Oh right, my mistake lol.

local tcs = game:GetService("TextChatService")
local muted = false
tcs.OnIncomingMessage = function(message)
    if not muted or message.TextSource.Team.Name ~= "Fans" then return end
    local prop = Instance.new("TextChatMessageProperties")
    prop.PrefixText = ""
    prop.Text = ""
    return prop
end