I’m trying to make a little messaging app, and this will obviously have to use Roblox chat filtering, so that’s what I implemented.
Here’s the function to filter text:
local function getFilteredMessage(text, fromPlayerId, toPlayerId)
local textObject = text
local filteredMessage
local success, errorMessage = pcall(function()
filteredMessage = TextService:FilterStringAsync(textObject, fromPlayerId, toPlayerId):GetChatForUserAsync(toPlayerId)
end)
if success then
return filteredMessage
elseif errorMessage then
warn("Error occured during filtering message | ", errorMessage)
if errorMessage == "Both users must be connected to the current server" then
return "The user you're trying to message isn't connected to your server."
end
end
return false
end
I tested running this by doing:
getFilteredMessage("hi", 2506737605, 2506737605)
When I do this, I get this error: Error occured during filtering message | Unable to cast double to token
, and the function returns nil
.
What is causing this to happen? Oh and, this is a server script. For now I’m just testing it by doing like I showed, to then implement my messaging.