Function problem

I'm trying to write a function that returns the number of items the player is wearing. This is the code:

x = 0
foreach (o, GetDirectChildren(player)) {
  if (GetBoolean(o, "worn")) {
    x = x + 1
  }
}
return (x)

However, when I try to access it I get an error message saying 'Error running script: Error compiling expression 'NumWorn()': Value cannot be null.Parameter name: key'. What am I doing wrong? It seems that no matter what the player is wearing, the result of the function should be an integer - so why is it being seen as null?


It sounds like in the function definition, you've got a parameter named 'key'. If you don't need to pass a parameter, you could try removing it.


No, the parameter list is empty.

I've just realised the problem - I'd forgotten to set the return type to Integer.


Log in to post a reply.

Support

Forums