The word doesn’t necessarily need to be bad to be problematic, the OP used the exact example of the word “bisexuals” to be problematic. Rightfully so as the word could be put together with another word to connote something bigoted or maybe a player doesn’t want to be called bisexual or similar. It’s best to keep the words safe as to make everyone happy.
Honestly I’d say just try making your own with 2 words combinations.
Dumb thing I said (because you need a user id with it) below
If you don’t want to get into trouble.
Wouldn’t FilterStringAsync be good enough?
If it fails, it’s roblox fault.
Tell me if i’m missing something.
Use a list with few words(like 5k max) of the most used ones in the English language, that should help reduce most bad words or weird input. I suggest you also pass all the words through the Roblox filter once and only keep those that don’t result in tags in your final list, that way you can get rid of most swear words that Roblox doesn’t like. Also you can add more pre-processing logic for your words, for example minimum and max length.
I used yours, @awry_y, @PokusPollo and @PokusPollo to check if the returned string is filtered or not.
local _success, _info = pcall(function()
local _randomWords = HttpService:JSONDecode(HttpService:GetAsync("https://random-word-api.herokuapp.com/word?number="..math.random(10,20)))
local _firstWord = firstToUpper(_randomWords[math.random(1, #_randomWords)])
local _filteredText = TextService:FilterStringAsync(_firstWord, _getUserId()):GetNonChatStringForBroadcastAsync()
while _firstWord ~= _filteredText do
table.remove(_randomWords, table.find(_randomWords, _firstWord))
_firstWord = firstToUpper(_randomWords[math.random(1, #_randomWords)])
_filteredText = TextService:FilterStringAsync(_firstWord, _getUserId()):GetNonChatStringForBroadcastAsync()
end
local _secondWord = firstToUpper(_randomWords[math.random(1, #_randomWords)])
local _filteredTextTwo = TextService:FilterStringAsync(_firstWord, _getUserId()):GetNonChatStringForBroadcastAsync()
while _secondWord ~= _filteredTextTwo do
table.remove(_randomWords, table.find(_randomWords, _secondWord))
_secondWord = firstToUpper(_randomWords[math.random(1, #_randomWords)])
_filteredTextTwo = TextService:FilterStringAsync(_secondWord, _getUserId()):GetNonChatStringForBroadcastAsync()
end
_sharedWords.Words = _randomWords
game:GetService("SharedTableRegistry"):SetSharedTable("_Words", _sharedWords)
workspace:SetAttribute("_serverName", ServerData.country_name.." / ".._filteredText.."-".._filteredTextTwo)
end)
Though some innocent words are filtered
I don’t really get why you’re using an external API for this, given the size of the list(assuming you don’t use a large dictionary, which isn’t needed for this) it should be easy to store within a Roblox module that you can just require. If I were you I would also only perform the processing of the data once to reduce time from that as well, by creating my own sublist of the original list that only has the non-filtered words that also match my criteria.
I know, but where would I get a lua table formatted word list?
You can use the following function(modify it according to your wanted programming language):
local function format(t: {string}): string
local result = "{"
for _, v in pairs(t) do
result ..= "\""..v.."\", "
end
result = result:sub(1, result:len()-2) --remove last comma and space
result ..= "}"
return result
end
The function assumes that no words in your wordlist have weird characters like "
in them, you should remove all words that have characters that aren’t an English letter before hand.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.