Local script won't find a child to PlayerGui

plr = game.Players.LocalPlayer

    plr:FindFirstChild("PlayerGui").CurrentOrder = script.Parent.Parent.Player.Player.Value
    game.ReplicatedStorage.Claimed:FireServer(plr.Name, script.Parent.Parent.Player.Player.Value)

Error on line 5, and it says: 15:29:44.156 - CurrentOrder is not a valid member of PlayerGui

I have looked at my script over and over again to see if everything checks out, and it does. Is there a problem I don’t see?

Can you show us your explorer view that shows “CurrentOrder” in the startergui or playergui?

Also, it may be because CurrentOrder hasn’t loaded yet.


Try that code.

Okay. Let me go get a picture.

You should be using WaitForChild in local-scripts. Try replacing it with the following line.

1 Like

Try using :WaitForChild() as it will wait for the-

Yeah… Just like that. :+1: :smile: :+1:

I’ve amended my first post with a possible solution.


Let me test. plr:WaitForChild(“PlayerGui”):WaitForChild(“CurrentOrder”) I’ll check in afterwards.

Script works! I don’t know why it didn’t load in when it had like a minute to do so, but whatever lol.

Roblox is sometimes pretty odd. Personally, I’m not sure of how Roblox processes all of the assets in studio and then compresses them all into a game, but there is 1 thing I know: it’s odd.

Make sure you use :WaitForChild() more often then not. A good use for them is to do something like: local Part = game.Workspace:WaitForChild("CoolestPartAround").

However, if you have a part in something like a model or folder, you may want to do this,
local Part = game.Workspace:WaitForChild("Model"):WaitForChild("FolderInModel"):WaitForChild("Part")
but you can do
local Part = workspace.Model.FolderInModel:WaitForChild("Part")

Plus, using it gives +5 cool kid points :+1: :smiley: :+1:

1 Like

Generally speaking WaitForChild is actually bad practice to use when not absolutely required, and is only ever necessary when trying to index things on the client (from localscripts). You use it to ensure what you try to index has finished loading.

This does not work the same as using WaitForChild on ‘Model’ and its children, in fact you are indexing the parent directly and this’ll error if it hasn’t loaded yet (the whole reason to use WaitForChild to begin with). You’ll want to avoid the situation entirely whenever possible, but when it isn’t make sure you don’t index directly anything that may not have loaded yet.

1 Like