"attempt to index a nil value (local 'xPlayer')" is causing a lot of errors

For the last few days I have had this error when starting my server and trying to do anything. I suspect it has something to do with esx_identity not “registering” my character as a player, or I am missing something to set an ID to the character. If anyone has an answer and can help it would be much appreciated.
Imgur

This is an example, it is the same error for everything.