Infinite yield possible?

I have a gamepass door that lets players with a specific gamepass in, but it doesn’t work because of this Infinite yield thing.

This is my gamepass script


local MarketplaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
local doorPart = game.Workspace["MBF Restaurant V3"].GroundBase.Gamepass:WaitForChild("GamepassDoor")
local doorPart2 = game.Workspace["MBF Restaurant V3"].GroundBase.Gamepass:WaitForChild("GamepassDoor"):WaitForChild("Door2")
local gamepassId = 15143732

if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamepassId) then
	print("Player owns pass.")
	doorPart.CanCollide = false
	doorPart2.CanCollide = false
else
	print("Player does not own pass.")
	doorPart.CanCollide = true
	doorPart2.CanCollide = true
end

This is how the gamepass door looks like in workspace
image

and this is the bug in the output tab
image

Maybe add more WaitForChild in your script for the path to the door.

that might work. I’ll try it out.

Based on the picture, “Door2” is not a child of “GamepassDoor”. It’s a child of “Gamepass”.

What happens here is that you are trying to get Door2 from GamepassDoor. My solution is to change :WaitForChild(“GamepassDoor”):WaitForChild(“Door2”) to :WaitForChild(“Door2”)

Then do WaitForChild("TheChild", 10 -- amount of time to wait for)
And if that is the error I don’t think that it is the infinite yield that is the problem. Because It never makes any problems when I get that it just mean it will keep searching forever.

oh wait, didn’t realize that i tried to get Door2 from GamepassDoor. Im stupid :sweat_smile:

Well be glad it is solved. :sweat_smile: