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

Why doesnt this work?

Asked by 8 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

I got this error not knowing what its about..

21:31:20.659 - ServerScriptService.MainScript:71: attempt to get length of local 'GameMaps' (a userdata value)

1 answer

Log in to vote
1
Answered by 8 years ago

An error that states anything concerning the message: attempt to get length of, implies you've used the # operator, or string.len function of the string library on a value that isn't a string (or an array, in the case of using the # operator).

As the error message says, somewhere in your script you've attempted to get the length of a userdata value, which the computer cannot interpret.

Solution

Now your question is very vague, so I'm not 100% sure this is your problem. But if you were trying to get the number of how many children are in an object, you can use the GetChildren method on whatever instance you're working with, accordingly with the # operator which will return the amount of elements in your array. Here's an example:

print(#workspace:GetChildren()) -- prints the amount children in the workspace. 

I'm not going to cover all about how functions, methods, arrays, ect work in this answer, but if you have any questions about them I'd be happy to help.

Ad

Answer this question