LocalScript not detecting a part in workspace

Hi there, I’ve tried everything to fix this, but a LocalScript handling gamepass boards inside of StarterPlayerScripts can’t seem to index a part in the gamepass board properly.

Here is the part of the script that is broken:

for _, workspaceObject in pairs(game.Workspace:GetDescendants()) do
	if workspaceObject.Name == "GamepassBoard" then
		for _, v in pairs(workspaceObject.Board.MainBoard.Part.SurfaceGui.ScrollingFrame:GetChildren()) do

It is indexing "workspaceObject.Board.MainBoard.Part which should work, however it isn’t. These are the descendants of the GamepassBoard in question:
image

I can also use the DevConsole to destroy the GamepassBoard’s part as a test. If you have any solutions, let me know!

1 Like

Is it giving you any errors about that it couldn’t find the part? Maybe add a wait, such as wait(5) before the loop or use WaitForChild to wait for certain children to exist before continuing?

1 Like

This is what comes out in the Client output.

Try this

wait(5)
for _, workspaceObject in pairs(game.Workspace:GetDescendants()) do
	if workspaceObject.Name == "GamepassBoard" then
		for _, v in pairs(workspaceObject.Board.MainBoard.Part.SurfaceGui.ScrollingFrame:GetChildren()) do

Or this

for _, workspaceObject in pairs(game.Workspace:GetDescendants()) do
	if workspaceObject.Name == "GamepassBoard" then
		local part = workspaceObject.Board.MainBoard:WaitForChild("Part")
		for _, v in pairs(part.SurfaceGui.ScrollingFrame:GetChildren()) do

Try turning off Streaming Enabled if you have it turned on. The reason why this should fix your problem is maybe because the gamepass board is not loaded on the client yet because it’s too far away for the Streaming Enabled max radius.

I suggest coding your gamepass board on the server and not on the client. (But you can keep the code on the client if you turn off Streaming Enabled)

Sorry if I am wrong or if I sound dumb, I’ve only been developing on Roblox for a year :sweat_smile: