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!