Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

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

Asked by 5 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?

game.Players.PlayerAdded:Connect(function(plr)
    plr:WaitForChild("PlayerGui"):WaitForChild("ScreenGui")
    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
    end
end)

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.

0
i dont think you have the path correct for plr:waitforchild....but i might be wrong User#19492 0 — 5y
0
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 User#19492 0 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 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.

0
Whoa, guess it's time to learn about RemoveEvent's! SchonATL 15 — 5y
Ad

Answer this question