Every time I press play I get that error. I have a GUI in PlayerGui named "Menu"

The script:

while wait() do
for _, v in pairs(game.Players:GetChildren()) do
local cont = v.PlayerGui.Menu.Container
cont.GoldVal.Text = v.leaderstats.Gold.Value
cont.LevelVal.Text = v.leaderstats.Level.Value
		end
end

Error output:

22:55:30.705 - Menu is not a valid member of PlayerGui
22:55:30.707 - Stack Begin
22:55:30.708 - Script 'ServerScriptService.Script', Line 3
22:55:30.709 - Stack End

4 comments

0

It seems that Menu isn't a child of PlayerGui just saying I'm not that good at scripting

0

Ew don't do it like that. 1. Don't use wait() as a condition. 2. Don't use GetChildren, use GetPlayers. 3. Disregard the last 2 because you shouldn't even be doing it like that. Just update the text on the client using a Changed event.

0

The reason your script does not work is because you used a server script. The "Menu" ScreenGui was clones locally into the PlayerGui, the server doesn't see it.

1

if you have FE enabled you have to use an event to fire to all the clients from the serverside, see tutorials on remote events