Profanityfilter
Based on game build 714014 | Last updated: 2026-03-08
Overview
ProfanityFilter is a utility class that enables configurable profanity detection. It maintains multiple named dictionaries, each containing lists of prohibited words for exact and loose matching. It is designed to be used server-side for filtering user-generated text such as names, chat, or UI inputs.
Usage example
local profanityfilter = TheSim:GetProfanityFilter()
profanityfilter:AddDictionary("en", {
exact_match = { [smallhash("badword")] = true },
loose_match = { "evil" }
})
if profanityfilter:HasProfanity("This contains badword") then
print("Profanity detected!")
end
Dependencies & tags
Components used: None identified.
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
dictionaries | table | {} | A map of dictionary names to dictionary configurations (each with exact_match and loose_match fields). |
Main functions
AddDictionary(name, data)
- Description: Adds a new profanity dictionary with a given name. Populates internal hashes for exact matches and decodes simulated strings for loose matches.
- Parameters:
name(string ornil) – Unique identifier for the dictionary; must be non-empty.
data(table) – Dictionary configuration containingexact_match(hash→boolean map) andloose_match(array of strings). - Returns: Nothing.
- Error states: No effect if
nameisnilor empty, or if a dictionary with the same name already exists.
RemoveDictionary(name)
- Description: Removes a dictionary by name from the filter.
- Parameters:
name(string ornil) – Name of the dictionary to remove. - Returns: Nothing.
HasProfanity(input)
- Description: Checks whether the input string contains any profanity, using both exact word matches (hashed) and substring-based loose matches.
- Parameters:
input(string ornil) – Text to scan for profanity. - Returns:
trueif any profanity is detected, otherwisefalse. - Error states: Returns
falseifinputisnilor empty.
Events & listeners
None identified.