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?
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!