Odd GUI output issue

Hey everyone!

I have a LocalScript in StarterPlayerScripts and a GUI in StarterGui. My plan is for when it is clicked, it will teleport the player who clicks it to a certain position. However, it is not working for some reason. The script below is isolated so it is not confusing, as I can write the rest of the script after this is fixed.

When I activate this script, the output reads:
12:15:21.741 - QueueGui is not a valid member of PlayerGui – QueueGui is the GUI name

Here is the script:

local player = game.Players.LocalPlayer
local pGui = player.PlayerGui
local gui = pGui.QueueGui

print(gui.Name)

try using the :WaitForChild() function to attempt to guarantee indexing after instantiation, so it doesn’t throw an error if it doesn’t exist at a time.

Dot syntax and :FindFirstChild() are more efficient than the :WaitForChild() function, don’t attempt to chain multiple :WaitForChild() functions if you care about efficiency.

Try using :WaitForChild() function.

I’m only using it for this one event, so this won’t affect performace. Thank you!

1 Like