string.match - bad key to string index (number expected, got string)

Hey all, so i’m kind of stumped on this,



local pattern = "([^%w%p%s]+)"
if string.match( ply:Name(), pattern ) then
...


keeps throwing bad key to string index (number expected, got string) 1. error - [C]:-1 2. __index -

Not sure why, has anyone else experienced this with string.match?

The interesting part is, although this is being thrown in the console, the functionality still seems to work as expected.