"PlayerGui is not a valid member of Player"

Please can anyone tell me how is this possible? When I try to change a GUI’s properties by mentioning PlayerGui it just gives me this error:

playergui

1 Like

Are you just referencing it by the dot (.)? Perhaps use WaitForChild instead, because everything isn’t going to load instantaneously

3 Likes

When I use :WaitForChild() it will give me this error:

palyergui2

I don’t know how PlayerGui is a nil value…

1 Like

USe a localscript instead

30 Chars

You should be using a local script as you can only script everything in the client side there and the PlayerGui is on the client side.

Maybe, you could access the PlayerGui in a script when wanting to announce the same announcement to all of the players at the same time? But, normally use LocalScripts for client sided stuff

If you want to announce something to all clients you could use a RemoteEvent. You should never reference PlayerGui through a server script, as it is bad practice.

1 Like

Use a RemoteEvent and fire the RemoteEvent and have a LocalScript listen to the RemoteEvent and change the Gui. Also what are u trying to achieve?

Yeah thats exactly what I do but I saw someone telling me that you can use the PlayerGui server sided. I didn’t believe him.

When I use a local script and get the playergui client sided I still get the problem.

@OP show the code you’re using, so we can know exactly what’s the problem (a snippet of it is fine)

@Tamzy3D the server can see the descendants of all players’ PlayerGuis

The server can see it but I don’t think it can be used unless a remote event is fired.

It can be manipulated on the server just like a local script manipulates it

Then why did @oPoisxn say that you can never reference it?

He said its Bad Practice

30

You can do it but its bad practice <— Correct

Thats why I don’t tend to use a script to manipulate the PlayerGUI

@Nerkonl For debugging purposes try printing each child of Player

It definitely can be manipulated the same on the server, however if you try to manipulate GUIs from the server, it comes with a server to client synchronization issue. Another thing to note, if you make a GUI visible on the server, it makes it visible for the client too. However, if the player were to close the GUI(a close button), the GUI would be invisible to the client but visible to the server. This is why all GUI related stuff should be handled from the client.

Yes, it still works but you should still use local scripts to reference something client sided.

When I try printing the contents inside of the players it just gives me nil…

I just want an explanation as to why this is happening.

Can you actually provide us with code? Just telling us stuff won’t help you or us.