Replicated Storage is unable to detect an object within it by a local script

Hello users, today I have a problem with scripts. So, I created a local script in ReplicatedFirst and wrote the following:

local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local DebugFunctions = game.ReplicatedStorage.DebugFunctions*

*DebugFunctions = Folder

The second line does not work because it says that the folder was not found even though it was there. Is there any way to fix this, what did I do wrong?

Have you tried :WaitForChild() ?

1 Like

Yes it worked, but I still haven’t figured it out well, what is WaitForChild used for?

Note: mark my response as the solution so other users can easily find it.

WaitForChild is used when you need to get something that might not have been loaded in yet when the line of code is run. In this case your script is probably loaded in before the folder so if you don’t wait the script would not find the folder but if you wait then it will continue loading all the other assets including the folder and then it will be found.

In summary it’s for when you need something that might not have been loaded in already.

1 Like

Thanks for the help: D, now I finally realized what it’s for.

1 Like