Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does ServerScriptService.BasicAdmin:1148: attempt to get length of a nil value mean?

Asked by 1 year ago

the script is too long to post

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

Any time you see attempt to ... a nil value in your code, you can be sure that there exists some variable that is not defined that should be.

This can happen in a few ways:

  • Forgetting to assign a value to a local variable
local assignLater;

-- (later never comes)

print(assignLater.something) --> attempt to index 'assignLater' (a nil value)
  • Accessing an object in your game that doesn't exist
print(workspace.doesntExist); --> attempt to index workspace for 'doesntExist' (a nil value)
  • Or any time where you are trying to perform some action on data that doesn't exist. Maybe the data was never defined, maybe it was defined at some point but then re-assigned to nil, etc.

In your case, somewhere in your code you are using the length operator (#) on a variable that isn't defined. This variable is most likely supposed to be an array or a string, since those are the only datatypes you can use this operator on.

You can simulate this error by doing the following:

local some_nil_value = nil;
print(#some_nil_value) --> attempt to get length of a nil value
Ad

Answer this question