Tryna make a whitelist system for a game but cant

local LETTERS = {
	"1",
	"2",
	"3",
	"4",
	"5",
	"6",
	"7",
	"8",
	"9",
	"0",
	"+",
	"-",
	"/",
	"*",
	".",
}
local WORDS = {
	"math",
}
for i,v in pairs(math) do
	table.insert(WORDS,i)
end

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	for i=1,#script.Parent.Text do
		local v = string.sub(script.Parent.Text,i,i)
		if table.find(LETTERS,v) == nil then
			for	_,vv in pairs(WORDS) do
				if string.match(script.Parent.Text,vv) then
					local let = string.gsub(script.Parent.Text,v,"")
					script.Parent.Text = let
				end
			end
		end
	end
end)

so I want it to detect if the words and letters match the 2 tables

local words = {"math"}

local textbox = script.Parent

textbox:GetPropertyChangedSignal("Text"):Connect(function()
	textbox.Text = textbox.Text:gsub("[%d%p]", "")
	for _, word in ipairs(words) do
		if textbox.Text:match(word) then
			textbox.Text:gsub(word, "")
		end
	end
end)

You can replace numerical integers (digits) with the character class %d and you can replace punctuation characters with the character class %p.

1 Like