Help With Infinite yield possible on 'ReplicatedStorage:WaitForChild("GameStatusVal")' Warning

I want to fix the error with the code, so that it doesn’t potentially mess with my game later, what is a fix?
(I’ve already tried switching it to FindFirstChild instead of WaitForChild, and it didn’t work.)

local RepStore = game:GetService("ReplicatedStorage")
local GameStatusVal = RepStore:WaitForChild("GameStatusVal")
1 Like

Did you make sure it’s in the right place in the replicated storage?

2 Likes

the “infinite yield possible on WFC” error is well what it says. It means that your yielding the script until the object is made but the game detects the object you are waiting for is still not avaliable even after a while so it is warning you the script might yield forever if the object is not created. If it doesnt break the code and it just takes a while for the value to be made there is nothing you can do to solve the issue. Also, why would you use waitforchild and findfirstchild interchangebly as they are very differnt. FindFirstChild() looks for the object you specify and returns true if it exists while WaitForChild() stops the script until the object you specify exists. WFC is waitforchild btw

1 Like

I have checked it multiple times, its in replicated storage.

Your code should work fine. You might want to check if you are checking in the right place in the replicated storage or if you object is being created correctly if you are creating it via script.

If you are creating your object via script, make sure it is not in a localscript because it won’t replicate to the server. This will cause your WaitForChild script to yield infinitely.

2 Likes

Ah ok, i didn’t know the difference between the two. (FFC and WFC) Glad to know the difference, thanks!

1 Like

always here to help :grin: if it makes it easier to understand WFC is the same as repeat wait() until FindFirstChild(Object) == true

1 Like

Ah ok, that should make it easier to understand, thank you!

1 Like

dont forget to mark one of us a solution if it fixes the issue :+1:

Alright, I will! (Though it does seem that Roblox is thinking there is an issue, when there isn’t, so there may not be a solution mark if I find it unnecessary, which i feel like has high potential to be the case.)

if the code runs find and it still gives you the wfc infinite yiled error there is not much you can do but ignore it