Instead of doing "local <variable> = <target>", instead just do "<variable> = <target>". To clarify what they meant, if you don't get it, is you're defining your two variables only when in the "if not should_revoke" which means you can't use them in the "if should_revoke" (else) as they aren't set to anything anymore and return nil.
Also, it may help if you do "elseif should_revoke" so that everything stays in one. Even though you are defining the ply_name and rank in the function, you're not setting them to anything.