Checking if player is console

Is their a good way to check if a player is console?

Check if the player is valid.
When you send a chat message from the console, for example; the player object in the OnPlayerChat hook is not valid.

So just

[lua]
if not ply:IsValid() then
[/lua]

or

[lua]
if not ValidEntity(ply) then
[/lua]

The second one,because ply may be invalid so you’d be calling the IsValid method on a nil variable.
ValidEntity and IsValid do a nil check before that so yeah,use the second one.

Are you using an OnPlayerChat hook? If you are, IsValid would work fine.