Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Roleplay Name - How to filter bad words and specific words?

Hi!

I was wondering how could I prevent players from using specific words such has "Naruto" or "Bob Ross" and also filter bad words in any kind of Roleplay Name changer?

I know there is Chat-Filtering for custom chats scripts but I couldn't find any for simple Name Changing systems.

1 comment

1 answer

✓ Accepted answer

This is a simple example. There are probably more sophisticated ways but here you go. I use string.find(string, searchString). string is the name and searchString is the banned word. You'll have to do the fine tuning yourself.

local BannedWords = {"Naruto", "Bob Ross"}

local function CreateName(nameChangedTo)
	local isBadName = false
	
	for _,banned in pairs(BannedWords) do
		--use string:lower() so all text are lowercased
		if string.find(nameChangedTo:lower(), banned:lower()) then
			isBadName = true
		end
	end
	
	if not isBadName then
		print("Yep, name is good to go")
	else
		print("Nope, bad name!")
	end
end

CreateName("Naruto Who?") --"Nope, bad name!"
CreateName("Bob Ross Who?") --"Nope, bad name!"
CreateName("naruto") --"Nope, bad name!"
CreateName("NNarutoooooo") --"Nope, bad name!"
CreateName("Bob Rose") --"Yep, name is good to go"
CreateName("Bobby Rossu")  --"Yep, name is good to go"

1 comment

1

Cool! Thank you so much! This is exactly what I was looking for!! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.