"Infinite yield possible on RemoteEvent"

Hello, so I am working on a MainMenu and recently I have encountered an error that is just bugging me. The error is occuring in a LocalScript which is located in a ScreenGui in ReplicatedFirst that is then given to the player’s PlayerGui. The error in the output is:

"Infinite Yield Possible on “ReplicatedStorage:WaitForChild(“ChangeTeam”)”

The relevant part of the script is:

local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("ChangeTeam")

I tried using only using game.ReplicatedStorage:WaitForChild(“ChangeTeam”) and game.ReplicatedStorage.ChangeTeam but both didn’t work too and got the same error. Any solutions would be really appreciated!

1 Like

Why don’t you just remove the WaitFotChild() and do:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = ReplicatedStorage.ChangeTeam

Didn’t work, I already tried that before posting this.

With the method I posted above, does it still say that in the output?

Also, are you testing it in-game or within Studio? If it is done in-game, have you tried publishing the game and then trying?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
repeat wait()
then break
local RemoteEvent = ReplicatedStorage.ChangeTeam

I had to tweak the code you sent a bit but it worked, so thanks.

Got the same error, but now my issue has been solved. Thanks for the reply anyway!

Alright, but just remember to use task.wait() instead of wait().