Replace every letter on a player's message

Hello im trying to replace every letter on a player’s message to ‘d’, but i do not know how could i do this. Thanks.

1 Like

Whoa whoa whoa, wait a second though. You’re aware Roblox demands the final message be sanitized through Roblox and must be filtered, right? It’s a subject of moderation against your experience if not.

And why not just disable chat if you are replacing the message to something like that?

1 Like

That’s what i was going to ask when they were going to give me the solution though
It’s a small test im making, im kind of new to scripting

By ‘d’ i meant any letter, sorry.

1 Like

Well, it’s a difficult question. It’s about intercepting messages that are sent through the ChatService, which is a fairly large and complicated module.

It’s far easier to just disable chat, isn’t that what the result would be equivalent to if every letter of a message is replaced with 'd’s

Im trying to get something like this:
image
Which get’s turn to this depending on how much letters you have.
image

Since i a bit new to scripting i dind’t knew that roblox wouldn’t filter the message.

I would be careful with that because you’re really not allowed to modify the output of chat to just anything, it must be sanitized and filtered through Roblox.

However, I would take a deep dive into ChatService.
You can do that by pressing play in Studio then copying what is created in Chat/
exiting play, then pasting what you copied into Chat/
then you may look through the modules

Ill better disable the chat, im not taking the risk of getting banned, thanks though.

If you can find exactly where the message is sent into the chat window,
then you could use something like

for i = 1, #message do
  if message[i] == " " then continue end
  message[i] = 'd'
end
print(message)

Alright, ill try, also, couldn’t you make something like a custom message filtering to make it not happen?

Yeah you can create custom filter, but at the end what’s custom-filtered still must be sent to Roblox. It’s a rule. So, I mean, if you create a custom filter and that converts all letters of a message to d’s then you send that to Roblox, Roblox could still filter that into ######### #### ###### so I can’t imagine the usefulness is worth the difficulty.

At the end of the day, you’d get something like:
dddd dddd #### dd ## ddddd #### ## ## dd dd d ### ddd

And you’ve gotta consider that not every language is english, so how would you filter spanish or german or arabic.

I think i could also use something called string.gsub() right?

yeah it would be something like
message = string.gsub(message, “%”, “d”)

with % a wildcard for any letter

I don’t know if string.gsub() handles white space

However, it’s very important that the final message is sent to Roblox. It’s a rule, you cannot avoid without moderation.

local message = "This is a message"
local length = message:len()
local result = string.rep("d", length)
print(result)

and:

local message = "This is a message"
local result = message:gsub(".", "d")
print(result)
1 Like

You can achieve this by adding your own module inside ChatModules (the code I gave you also filters the message before sending).

You are going to need a server script inside ServerScriptService, and a module inside that script.

-- SERVER SCRIPT

local CTS = game:GetService("Chat")

local convert = script.Convert
local mod = convert:Clone() do
	mod.Parent = CTS:WaitForChild("ChatModules")
end
-- MODULE SCRIPT

local TS = game:GetService("TextService")
local PS = game:GetService("Players")

local id = "editText"

local function DoFilter(speaker, message, channel)
	local convert = string.gsub(message.Message, "%w", "d")
	local filtered
	local player = PS:FindFirstChild(speaker)
	
	local success, error = pcall(function()
		filtered = TS:FilterStringAsync(convert, player.UserId):GetNonChatStringForBroadcastAsync()
	end)
	
	if success and filtered then
		message.Message = filtered
	else
		warn(error)
	end
end

local function RunModule(CTS)
	CTS:RegisterFilterMessageFunction(id, DoFilter)
end

return RunModule

1 Like