Is not a valid member even though it is

i keep getting this error saying its not a vaild member even though it is

the code

for i , v in pairs(ReplicatedStorage.Lobbies:GetChildren()) do
		local lobby = v
		CreateLobbyThingy(lobby, lobby.Mode, lobby.Players:FindFirstChild())
	end

Error: Mode is not a valid member of Folder "ReplicatedStorage.Lobbies.CybersDevAccount_lobby"

And here u can see Mode exists
image

Use :getdescendants instead of :getchildren. Because you’re only getting the children of lobbies and you dont get the children of cyberdevaccount_lobby. So with getdescendants you get all off the descendants. (Sorry if not good explanation im not good at explaining things)

Also, check if lobby.name == "mode"

3 Likes

The error message is telling you that the Mode property does not exist on the Folder object that you are trying to access it from. This is likely because the Folder object is a Lobby object, not a Folder object.

In the code you provided, you are using the pairs() function to iterate over the children of the ReplicatedStorage.Lobbies object, but you are assuming that each child is a Folder object and trying to access the Mode property on it. This will not work because the children of ReplicatedStorage.Lobbies are likely Lobby objects, not Folder objects.

To fix this issue, you need to check the type of each child before trying to access its properties. You can use the instanceof() function to check the type of an object and make sure it is a Lobby object before trying to access its Mode property.

Here is an example of how you can fix this issue:

Copy code

-- Get the Lobbies folder
local lobbiesFolder = game.ReplicatedStorage.Lobbies

-- Iterate over the children of the Lobbies folder
for i, child in pairs(lobbiesFolder:GetChildren()) do
  -- Check if the child is a Lobby object
  if child:IsA("Lobby") then
    -- If it is a Lobby object, get the Mode and Players properties
    local lobby = child
    local mode = lobby.Mode
    local players = lobby.Players:FindFirstChild()

    -- Create the lobby thingy with the mode and players
    CreateLobbyThingy(lobby, mode, players)
  end
end

With this code, you will only try to access the Mode and Players properties on objects that are Lobby objects. This will fix the error and allow your code to work as expected.

1 Like
for i , v in ipairs(ReplicatedStorage.Lobbies:GetChildren()) do
if v.Name == "CybersDevAccount_lobby"  then
		local lobby = v
        local mode = v:WaitForChild("Mode")
		CreateLobbyThingy(lobby, mode, lobby.Players:FindFirstChild())
end

	end

This also might work ^
Also make sure mode exist on the server… Depending on your code you might be making mode on client and then trying to get it from the server.

1 Like