Still have questions? Join our Discord server and get real time help.
Log in to vote

Help with updating lobby list (like in COD lobbies)?

Asked by 2 years ago

This script is meant to update the player list ( much like in COD lobbies ) when a new player joins. However it says that ScreenGui is not a child of PlayerGui despite it definitely being there. Any idea whats going on?

    for i,v in pairs(game.Players:GetChildren()) do
        local ptclone = game.ServerStorage.PlayerTemplate:Clone()
        ptclone.Parent = v.PlayerGui.ScreenGui.MainMenu.Multiplayer.Players
        ptclone.Name = plr.Name
        ptclone.PlayerName.Text = plr.Name

When I use wait(5) ( to see if its just acting like this because the player isn't fully loaded in )

17:57:18.348 - ScreenGui is not a valid member of PlayerGui

When I use :WaitForChild("ScreenGui")

17:55:56.771 - Infinite yield possible on 'Players.Player2.PlayerGui:WaitForChild("ScreenGui")'

NOTE: This works in quick test play, but doesn't work when I use the test tab to start a server.

i dont think you have the path correct for plr:waitforchild....but i might be wrong SweetAsCreampie 55 — 2y
local Players = game:GetService("Players") function onPlayerAdded(player) print(player.Name .. " has entered the game") end --When a player joins, call the onPlayerAdded function Players.PlayerAdded:connect(onPlayerAdded) try something like this SweetAsCreampie 55 — 2y

1 answer

Log in to vote
Answered by 2 years ago
Edited 2 years ago

If you are on Filtering Enabled, the problem that is occurring with the infinite yield is because you are trying to look into a client's PlayerGui, which you can't do on the Server Side of a game. It works in studio because Test Play in studio ignores Filtering Enabled and allows you to cross the line between Server and Client connections. On a regular server, Filtering Enabled is not ignored. You would need to create a RemoteEvent to be fired from within that OnJoin Event you have and have the clientside handle all the GUI placement, cloning, and editing.

Whoa, guess it's time to learn about RemoveEvent's! capinbuilda 15 — 2y

Answer this question