Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Waiting Before Connecting :GetPropertyChangedSignal() ?

I'm basically trying to make a lobby system for multiplayer but i'm running into this issue, so basically I have a system to connect the lobbies up and when the value of the lobby's amount of players gets changed it changes it for all clients. The issue is I have a loop to begin with but it already has connected the function up to a nil value which was suppost to be set in the loop before connected. Here are the parts of the script with the issue:

LobbyFound = false
game.Workspace.Lobbys.ChildAdded:Connect(function()
	if LobbyFound == false then
		LobbyList = game.Workspace.Lobbys:GetChildren()
		for i, v in pairs(LobbyList) do
			if LobbyList[i].Name == script.Parent.Parent.Name then
				LobbyFound = true
				LobbyLocation = LobbyList[i]
			end
		end
	end
end)
LobbyLocation:GetPropertyChangedSignal("Value"):Connect(function()
	if Status == "Join" then
		script.Parent.Text = "Join" .. LobbyLocation.Value .. " / 4"
	else
		script.Parent.Text = "Leave" .. LobbyLocation.Value .. " / 4"
	end
end)

1 comment

0

And no Im not going to set up the lobby variable manually because that would be boring.

1 answer

I don't know how to answer the question exactly but I just want to point one thing out.

LobbyFound = false
game.Workspace.Lobbys.ChildAdded:Connect(function()
    if LobbyFound == false then
        LobbyList = game.Workspace.Lobbys:GetChildren()
        for i, v in pairs(LobbyList) do
            if LobbyList[v].Name == script.Parent.Parent.Name then
                LobbyFound = true
                LobbyLocation = LobbyList[v]
            end
        end
    end
end)
LobbyLocation:GetPropertyChangedSignal():Connect(function()
    if Status == "Join" then
        script.Parent.Text = "Join" .. LobbyLocation.Value .. " / 4"
    else
        script.Parent.Text = "Leave" .. LobbyLocation.Value .. " / 4"
    end
end)

You are supposed to use "v" on line 6 and 8. The reason is because the child would be the second value listed, not the first. "i" is the amount of children that it has gone through

1 comment

0

that was not the problem, I just wanted to point that out, but sorry, I don't know how to fix this

This discussion is preserved as it was. New answers, comments, and votes are closed.