however, that results in an error “plate is not a valid member of Folder “Workspace.Blue” - Client - LocalScript:32” I am also planning to add more items into the folder, so I don’t want to WaitForChild all of the parts I need. Is there a solution to wait for all the parts to load inside of a folder
Make sure the loop comes before the code you are trying to execute that indexes the colors. If it still doesn’t work, you could try brute forcing it and just putting a wait function for a set amount of time so the game has time to load.
local ContentProvider = game:GetService("ContentProvider")
local status = 0
-- 0 = blue, 1 = middle, 2 = red
local blue = workspace:WaitForChild("Blue")
local red = workspace:WaitForChild("Red")
function setMiddle()
end
function changeColors(newStatus)
local color
if newStatus == 0 then
color = blue
elseif newStatus == 2 then
color = red
else
setMiddle()
return
end
for key, value in color:GetChildren() do
print(value.Name)
if value:IsA("BasePart") then
value.Transparency = 0
value.CanCollide = true
end
end
end
repeat task.wait() until game:IsLoaded()
changeColors(status);
print("running2")
This doesn’t work, however, If I replace the loop with say, task.wait(1), it works. But I don’t want to wait a set amount of time in case someone loads in at a different time
It should… Ensure that line of code is stated before the pair loop starts. If it does not, well… The parts are either just simply nonexistent or your Studio’s broken.
So this is what my folder is looking like at the moment
With the task.wait loop the console prints
which is after I call changeColors()
however with wait(1), it prints
Make a loading screen. Make sure it’s server-sided so it displays the same for everyone. It could load for 2-3 seconds to ensure everything has loaded, as of right now that’s the most efficient way to do so.
Instead of using a local script, use a legacy script. This ensures the loading screen displays on everyone’s screen at the same frame, and at the same time.