Gui nil even tho it exists

ok so i got this screengui called maingui but when i print PlayerGUI:GetChildren() it turns out to not exist?
playergui during runtime:
image
print statement:
image
pls help

Please post the script that you are using. My guess is that the game doesnt even have time to put all the childs in playerGui before you ask to print it. You should wait until the player spawns to set the playerGui:GetChildrens()

this script runs when the player buys an item, which is more than enough time for the gui to load in

You are probably calling the variable too early. Is the local childrens = playerGui:GetChildrens() inside the buyEvent’s scope?

And are you calling it from the server or from the player?

How does the gui get created? since playerguis exist on server by default unless you create one by yourself manually. Alternatively if you wanna get playerguis on server you can use.

game:GetService("Players").PlayerAdded:Connect(function(Player)
   for _,v in Player:WaitForChild("PlayerGui"):GetChildren() do
      print(tostring(v))
   end
end)

can you show your code?


Instances created by the client cannot be seen on the server.