Local Script claims that a part does not exist, but it does?

So I have very simple line of code but it errors each time.
I’ve already tried to add wait until game.IsLoaded stuff and similar things like that.
Turns out if I add specifically wait(1) before everything it works fine, but still giving me the same error sometimes

I assume that it’s because the workspace doesn’t get enough time to replicate to the client, but how do I wait for it instead of adding wait(n)?

local BlockUpgradesFrame = workspace.Block.BlockUpgrades.Screen

image

image

Sounds like a simple WaitForChild function will do.

local BlockUpgradesFrame = workspace.Block.BlockUpgrades:WaitForChild("Screen")

Do I really have to do it for each new similar error I get

The WaitForChild is primarily used while the game is still loading or you summon new instances that take a few milliseconds longer to load in than the code runs.

Once the wait time to find the child has finished, there’s a good chance that all the other instances have already loaded, so you do not have to use it for that path anymore.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.