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.
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"