playercount = 0


mob = /mob/player


playernum = playercount

playernum = 0

// - - - - - - - - - - - - - - - - - - - -


Click( atom/g )
pnum = usr.playernum

Problem description:

To begin with, I should mention that the commented dashed line was inserted to separate the two main phases that coincide to produce this error. Let's navigate from top to bottom. I created a variable called playercount that is used within the mob/player block to assign a number to each player successively at login time. So, in essence, the order of arrival is determined. Fair enough, now let's jump to the block of code beneath the dashed line. When I attempt to call the user's playernum value using usr.playernum, the compiler states that this variable is undefined. It is quite clear that I did, in fact, initialize and use this variable in the mob/player segment. Is it possible that this variable does not belong to the user, although the user is the only being who can call the Click() proc beneath client? I have tried just about every solution I could think up to solve this seemingly simple problem, but to no avail. Any potential solution to this would be greatly appreciated.
The variable usr is of type /mob (not to be confused with what the variable is pointing to, which could be a /mob/player), no matter what you do. If you wish to access the variables of another type, you have to typecast it, like so:

var/mob/player/P = usr

The istype() is used to ensure that usr is the type that we said it is, to avoid a runtime error.

What you wrote originally was equivalent to, "You will be given an animal. Tell me the color of its bill." The compiler says, "not all animals have bills!" and throws an error. So, instead, you have to say, "You will be given an animal. It will be a duck. If it is a duck, tell me the color of its bill."