I tried the same script on the server, and it works but you can’t tell which chats are team chats or whispers. You might think “you can just find what ones have /t or /w” but no, that’s only for the first initial message.
I was able to achieve what you want by detecting when a child is added to the chat scroller (the frame that holds all chat messages).
Below is the code that I used to achieve it!
local Scroller = game.Players.LocalPlayer.PlayerGui:WaitForChild("Chat").Frame.ChatChannelParentFrame.Frame_MessageLogDisplay.Scroller
Scroller.ChildAdded:Connect(function(child)
local TextLabel = child.TextLabel
local Type = ""
if #TextLabel:GetChildren() == 0 then
Type = "System"
elseif #TextLabel:GetChildren() == 1 then
Type = "Normal"
else
local IsTeam = false
for _, button in ipairs(TextLabel:GetChildren()) do
if button.Text == "{Team}" then
IsTeam = true
end
end
if IsTeam then
Type = "Team"
else
Type = "Whisper"
end
end
print(Type)
end)
Type will either be “System”, “Normal”, “Team”, or “Whisper”