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.
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.