[Help] String.find help

  1. What do I want to achieve?

When I test it out, it says it find a blacklisted letter but I did not write any of those, I don’t have a lot of explanation I just find it weird that it doesn’t work

		if msg:sub(1, 5) == "/pay " then
			if string.find(msg:sub(5), "e") or string.find(msg:sub(5), "E") or string.find(msg:sub(5), "-") or string.find(msg:sub(5), ".") or string.find(msg:sub(5), ",") then
				
				print("Found blacklisted letters")
				
			else
				
				print("Work?")
				
			end
		end

If you can help me I would appreciate it

It’s because string.find is pattern matching. You should use [[]] strings or turn pattern matching off. Additionally, you can use an array of bad characters.

local badCharacters = {
	"e"; "E"; "-"; "." ; ",";
}

for _, character in pairs(badCharacters) do
	if ( string.find(msg:sub(5), character, 1, true) ) then
		print(("Blacklisted character found. Character was %s"):format(character))
		return
	end
end

print("No blacklisted character")
1 Like

Only thing I don’t get is the " 1, true", what is that for