Need help with script

So basically i have this script, and its suppose to change a user from the “Guest” rank to the “Members” rank if they have “[Pd]” in their name.

The only issue i have is that anyone with [, ], P, D in they’re name, will be moved to the members group.
Also if they dont have the tag it removes them from the group.


function PLUGIN:PlayerInitialSpawn( ply )
	local name = ply:Name()
	local g    = ply:EV_GetRank()
	local sid  = ply:SteamID()

	if string.find( name, "[Pd]" ) and g == "guest" then 
		ply:EV_SetRank("respected")
	end

	if not string.find( name, "[Pd]" ) and g == "respected" then
		ply:EV_SetRank("guest")
	end
end

[lua]string.find( name, “[Pd]”, 1, true )[/lua]