Unable to moderate strings through roblox filter

I am currently making a custom chat system. Everything works perfectly, but there is one last issue i’ve been unable to resolve:
No matter what I do or type, any message I send doesn’t get any kind of moderation through the filters im implementing. The messages return the exact same as I send them. This is a big issue, and I very much need it solved as soon as possible.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TextService = game:GetService("TextService")
local Chat = game:GetService("Chat")

local EventsFolder = ReplicatedStorage:WaitForChild("Events")
local MainEvent = EventsFolder:WaitForChild("ChatController")

local lastMessages = {}

local function filterMessage(msg, fromUser : Player)
	local result
	
	local success, err = pcall(function()
		result = TextService:FilterStringAsync(msg, fromUser.UserId)
	end)
	
	if success then
		return result
	end
	warn(err)
	return false
end

local function getFilteredMessage(text :TextFilterResult, recipient)
	local result
	
	local success, err = pcall(function()
		result = text:GetNonChatStringForBroadcastAsync()
	end)
	
	if success then
		return result
	end
	
	warn(err)
	return false
end

function ProcessMessage(Player : Player, Message : string)
	if lastMessages[Player] and tick() - lastMessages[Player] < 0.3 then
		return
	end
	
	lastMessages[Player] = tick()
	
	local textm = getFilteredMessage(filterMessage(Message, Player), Player)
	
	print(textm)
	
	MainEvent:FireAllClients(textm or "########", Player.Name)
end
MainEvent.OnServerEvent:Connect(ProcessMessage)

I’ve looked all over devforum and youtube. All tutorials seem to follow this process, but it just won’t do anything. Any help is appreciated!

If you’re testing in Studio, text will be returned unfiltered; however, it should work as-intended in a live game. Are these issues still occurring in a live server?

Had that same exact thing happen to me, its not a bug. Chat filtering does not work in studio, publish the game and play it from roblox and it should work there

Strange. Last night when i posted this it also wasn’t working in Roblox, but now trying it again it seems to be working as intended. Anyway, thanks for the reply!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.