Ok so I'm trying to make a censorship filter for my chat, however the method I'm using makes it so that capital letters return as lower case. Obviously they do this because of the string.lower, but how can I make it so that it censors and returns to the normal case?
for N,T in ipairs (CensoredList) do
Button.Text = string.gsub((string.lower(Button.Text)), (string.lower(T)), "###")
end
Current revision attempt -
local original = Button.Text
local lower = string.lower(original)
for _, word in next, CensoredList do
local i, j = string.find(lower, word)
while i and j do
original = string.sub(original, 1, i - 1) .. string.rep("#", j - i + 1) .. string.sub(original, j + 1)
i, j = string.find(lower, word, j)
end
end
Button.Text = original

5 comments
Why not? It could be a good learning experience. However, this function is great if you want the exact filtering that Roblox uses.
i need to make my own, and the filterforasync only works with traditional roblox chat
No it doesn't, the function returns the string filtered.
For the context of a ROBLOX game, you must filter user input through FilterStringForPlayerAsync.
It's still a good learning experience, but the one you write on your own isn't what you should be using to filter text in your ROBLOX game.