Iterating through a table errors

Hey everyone! I’m trying to make a main menu GUI and I want it to disable every GUI in the table when the game starts.

The problem is, I always get the error

Players.oopacity.PlayerGui.MenuApp.LocalScript:16: attempt to call a nil value

This is the script:

local guis = {
	playerGui:WaitForChild("HotbarApp")
}

for _, g in pairs(guis:GetChildren()) do
	g.Enabled = false
end

(there’s only 1 gui in the table right now because the game’s new and I haven’t made any GUI’s but I’ll add more later on)

Any help is appreciated, thank you so much!

You don’t need :GetChildren() to iterate a table, :GetChildren() is used to get a table of an instance’s children

1 Like