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

[SOLVED!] Why does it return "ScreenGui is not a valid member of PlayerGui"?

Asked by 5 years ago
Edited 5 years ago

Please, help me! I'm making a new game, and i made a script to change player Gui (LocalScript) so for me,

game.StarterGui.ScreenGui.something.Text = ...

didn't work. So i did

game.Players.LocalPlayer.PlayerGui.ScreenGui.something.Text = ...

of course I didn't make a script to change Text of "something" but that's just a similliar example. Well, the second one usually works. But sometimes it returns

ScreenGui is not a valid member of PlayerGui

error. Well, From what I know- it means that when the script was executed, then PlayerGui didn't have "screengui" inside it-yet. I guess it's because PlayerGui didn't fully load. Of course, in playtest it works all the time, because the player loads instantly with the server. But in the studio server test (in studio>test>local server start) the server loads first, and then the Player loads, so it may be because of this. Game script is a server script of course, while i used LocalScript just for GUI changing. Just in answer, do an example code on how to change exampletext's Text value to something (locally, not from server). Well, this way to make it works even if the Player loads later than the server does. Does anyone understand me?

0
hello i hope you see this: cherrythetree 130 — 5y
0
Well you forgot that does ScreenGui exists in the PlayerGui? Make sure you put the ScreenGui in the PlayerGui with a script, if not. The error will say that, it means you want to do something on PlayerGui but does not have a child named ScreenGui cherrythetree 130 — 5y
0
I have fixed this, but thanks for help anyway! diamindhunter82 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I fixed this! I used Instance:WaitForChild() scripts. You don't need to answer that! Just did:

a = game.Players.LocalPlayer:WaitForChild("PlayerGui")
b = a:WaitForChild("ScreenGui")
b.sometext.Text = "..."

works fine now!

Ad

Answer this question