Lol, sorry if you misunderstood. I did not fix the error, you asked 'What exactly are you trying to do?' and I said fix the error. I could probably gut it and everything would be fine. Also, I could perhaps add a conditional to make sure text exists, is a string, and has a .find method
if not ( ( text ) and ( type( text ) == "string" ) and ( text.find) ) then return end
Would most likely fix the error, yes. Although I cannot find where the function is being called.