Text replacer local script that replaces ANY occurences

i dont really know how to describe this in text but whatever.
so what im trying to make is a text replacer script, for a require.
but heres the problem. like, string.gsub only replaces text that is exactly the same as the pattern, so if i do like

print(string.gsub('Text','text','t3xt'))

it returns Text 0
so yeah this is basically that one “anti-ban” script but way less annoying (it doesnt replace all the text and force presses enter) i probably shouldnt have made this
this is my script:

local keywods:{[string]:string} = {
	['ban'] = 'b4n';
	['kick'] = 'k1ck';
	['shutdown'] = '5hu7d0wn';
	['crash'] = 'cr4sh';
}
local keywords:{[string]:string} = keywods
game["Run Service"].Heartbeat:Connect(function()
	for i,v in pairs(game.Players.LocalPlayer.PlayerGui:GetDescendants() :: {Instance}) do
		if v:IsA('TextLabel') then
			for keyword,toreplace in pairs(keywords) do
				local g = {string.find(v.Text:lower(),keyword)}
				-- do something idk
			end
		end
	end
end)
1 Like
local keywods = {
	['ban'] = 'b4n';
	['kick'] = 'k1ck';
	['shutdown'] = '5hu7d0wn';
	['crash'] = 'cr4sh';
}

local function filt(str: string)
	local msg = string.split(str, " ")
	local returnmsg = ""
	for _, v in pairs(msg) do
		local filt = v
		for i, j in pairs(keywods) do
			if string.find(v:lower(), i) then
				filt=string.gsub(v:lower(), i, j)
			end
		end
		returnmsg=returnmsg..filt.." "
	end
	return returnmsg
end

Example:

print(filt("Ban and crash all!!!")) --print "b4n and cr4sh all!!!"

thanks!! this should stop admin abusers in games

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.