Why am I getting an infinite yield?

I’m trying to set a variable to a part in my workspace, but the output window is giving me infinite yield. Here’s my script:

local crateOpeningCutscene = game.Workspace:WaitForChild("CrateOpeningCutscene")
local camPosPart1 = crateOpeningCutscene:WaitForChild("CameraPos1")

Here’s the explorer window:
Screenshot 2023-06-17 133821

It’s saying infinite yield for CameraPos1. Why is this happening?

1 Like

Is it possible that the camera parts are unanchored and have disabled collisions? They may be falling into the void.

2 Likes

The other thing I was wondering is if this is a LocalScript and you have StreamingEnabled turned on. If that’s the case, then the CameraPos1 part won’t exist until you get near enough to it.

Here’s some more info on StreamingEnabled

3 Likes

Yep, looks like that’s the problem. Is there a way I could fix this using remote events or remote functions?

1 Like

If you look at the article I linked, it does talk a bit about ways to handle these scenarios. I’m not entirely sure what your use-case is here so I can’t really advise without more info. I think you can probably just do something like this:

local crateOpeningCutscene = game.Workspace:WaitForChild("CrateOpeningCutscene")

crateOpeningCutscene.ChildAdded:Connect(function(child)
	if (child.Name == 'CameraPos1') then
		-- do stuff with CameraPos1.
	end
end)
1 Like

I just looked at the article, and it doesn’t talk about what I need. The part is so far away from the play area that it will never be streamed in, so how could I fix this? is there any way to modify just that part’s streaming or would I have to change the streaming mode?

1 Like

You can use Atomic streaming mode on the folder (might need to be a model, unsure.)

1 Like

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