I need to find children of PlayerGui, but it keeps resulting in infinite yield or an error. Here is the script:
local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local testingScreen = playerGui:WaitForChild("TestingScreen")
local testingFrame = testingScreen:WaitForChild("TestingFrame")
local manageResults = testingFrame:WaitForChild("ManageResults")
local openManageResults = manageResults:WaitForChild("OpenManageResults")
The script is able to find player and playerGui without a problem, but It can’t find TestingScreen. Here is the explorer window for starterGui:
local player = game:GetService("Players").LocalPlayer
local playerGui = player.PlayerGui
local testingScreen = playerGui.TestingScreen
local testingFrame = testingScreen.TestingFrame
local manageResults = testingFrame.ManageResults
local openManageResults = manageResults.OpenManageResults
This will cause an error instead of infinite yield error. This will not fix the problem. @Valkyrop if it’s a server script he wouldn’t be able to use .LocalPlayer, thus not being able to find the PlayerGui itself:
I think the issue is you reusing the WaitForChild in the children of the TestingScreen. I tried this and it seems to work fine for me.
Instances:
Code:
local PLAYERS = game:GetService("Players")
local LOCALPLAYER = PLAYERS["LocalPlayer"]
local PLAYERGUI = LOCALPLAYER:WaitForChild("PlayerGui")
local GUI = PLAYERGUI:WaitForChild("TestingScreen")
for INT, ITEM in pairs(PLAYERGUI:GetChildren()) do
print(INT, ITEM)
end