Assistance with "LocalizationTables"

What do I want to achieve? I would like to modify a localization table to block key words that most backdoor scripts may include. (EX: “require”, “loadstring”, etc)

What is the issue? I cannot, for the life of me, find a way to block a portion of a total string. (EX: “require(123)” → “blocked(123)” or “local a = loadstring” → “local a = blocked”)

What solutions have I tried so far? I’ve looked on the Developer Hub, but alas, no luck.

I have a short local script to handle this.

local LocalizationService = game:GetService("LocalizationService")

local BlockedString = {
	"execute",'executor','exec',"r6","r15","hub","god",
	'require','getfenv','setfenv','_G','loadstring','game','getService','workspace'
}
local strs = {}
local extra = "blocked"

for i,v in BlockedString do
	table.insert(strs,v)
	table.insert(strs,v:sub(1,1):upper()..v:sub(2))
end

for i, v in pairs(strs) do
	local localTable = Instance.new("LocalizationTable")
	localTable.Parent = LocalizationService
	localTable:SetEntries({
		{
			Key = "0x" .. i,
			Source = v,
			Values = {
				["en-us"] = extra,
			}
		}
	})
end

You need to use string.gsub for this. Your script only matches the exact word, not any part of a string that contained those words.

local LocalizationService = game:GetService("LocalizationService")

local BlockedString = {
    "execute", "executor", "exec", "r6", "r15", "hub", "god",
    "require", "getfenv", "setfenv", "_G", "loadstring", "game", "getService", "workspace"
}

local strs = {}
local extra = "blocked"

-- Helper function to block keywords in a given string. Use str.gsub.
local function blockKeywords(str)
    for _, keyword in ipairs(BlockedString) do
        str = str:gsub(keyword, extra)
    end
    return str
end

local localTable = Instance.new("LocalizationTable")
localTable.Parent = LocalizationService

for i, v in ipairs(BlockedString) do
    local blockedStr = blockKeywords(v)
    localTable:SetEntries({
        {
            Key = "0x" .. i,
            Source = v,
            Values = {
                ["en-us"] = blockedStr, -- Modify dynamically
            }
        }
    })
end

If this solution was helpful or resolved your issue, kindly mark it as the solution. Thank you!

Hello!

Thank you for the reply, but this seems to be A.I. slop. This would be fine, if the script actually worked. (It doesn’t due to the function “blockKeywords” not being ran on the input to the LocalizationTable.)

Please do not attempt to assist people with generative systems such as “ChatGPT.”