Attempt to call a nil value

Hey I need help with accessing a level in a players base, this is a reference (Ignore the parts a,b,c,d they are for the level)

image

When a player joins the game the level model goes into the players base level folder, and whenever I start the server up, I get the error issued in the Title

This is my code:

game.Players.PlayerAdded:Connect(function(player)
	local playerName = player.Name	
	
	local base = workspace:WaitForChild(playerName.."-base")
	local levelFolder = base.Level
	local level = levelFolder:GetChildren()
	local levelParts = level:GetChildren()

My goal is to get the levelParts table and use it for loops and such, but that last line gives the error " attempt to call a nil value"

The error means that your trying to call something which doesn’t exist.

Level is a table which is the children of a instance, so try your level variable to something else or doing something such as level[1]:GetChildren().

2 Likes

Woops, this is a table calling GetChildren which doesn’t exist.

1 Like

Yeah i forgot to treat the Level as a table, I thought if it has only 1 instance that it will not be a table, thanks for the help!