Attempt to get length of upvalue 'mapschildren' (a nil value)

So this script is a server script that is in workspace. I encountered this problem when I was testingmy game. The only error that came up was:

 18:11:06.517 - Workspace.MainGame.LiftScript:15: attempt to get length of upvalue 'mapschildren' (a nil value)

So on Line 15 it said this:

local randommap = mapschildren[math.random(1, #mapschildren)]

and mapschildren is:

local mapschildren game.ServerStorage.Maps:GetChildren()

So I am really confused why this error popped up. Maybe roblox is broken? Or maybe there is a solution to this.

1 Like

You forgot the equal sign for mapschildren. If you aren’t defining variables, it will always return nil.
For example:

local Thing --is automatically set to nil due to not defining anything
local Thing2 = true --is set to a value
local Thing3 workspace:GetChildren() --there's no equal sign, so
--you're just getting the children

Make sure you check your stuff.

1 Like