Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this giving me a thing in output saying Infinite Yield Possible?

local gamePassService = game:GetService("GamePassService")

local closed_position = script.Parent.Position
local open_position = Vector3.new(434.199, 118.508, -78.223)
local passid = script.Parent.Gamepass:WaitForChild("Gamepass").Value

local opening = false
local closing = false

local function slideDoor(slideTime, startPos, endPos)
  	local movingOpen = opening
  	local loopBroken = false
    local slideInterval = (endPos - startPos) / (30 * slideTime)
    for i = 1, (30 * slideTime) do
    	if opening ~= movingOpen then
      		loopBroken = true
      		break
      	end
   		wait(1 / 30)
    	script.Parent.Position = script.Parent.Pos + slideInterval
    end
  	if not loopBroken then
    	opening = false
    	closing = false
  		script.Parent.Position = endPos
  	end
end 
--Test ok
while wait() do
  	local playersCloseBy = false
	for i, plr in pairs(game.Players:GetPlayers()) do
        if gamePassService:PlayerHasPass(plr, passid) and plr.Character then
      		print("Ye boi")
      		local distance = (plr.Character.Torso.Position - part_position).magnitude 
            if distance < 5 and not opening and script.Parent.Position ~= open_position then
      			playersCloseBy = true
            end
        end 
  	end
	if not playersCloseBy and not closing and script.Parent.Position ~= closed_Position then --Closes door
  		opening = false
  		closing = true
    	slideDoor(3, script.Parent.Position, closed_position)
	elseif playersCloseBy and not opening and script.Parent.Position ~= open_Position then --Opens door
  		opening = true
  		closing = false
  		slideDoor(3, script.Parent.Position, open_position)
  	end
end

22:08:31.411 - Infinite yield possible on 'Workspace.VIP.P2.Gamepass:WaitForChild("Gamepass")' Please help.

2 comments

0

Probably because there isn't anything named "Gamepass" under Gamepass.

0

That is a warning you see any time you use :WaitForChild() without its second optional timout argument. It's warning you that if it never finds the child, it will yield forever and never execute the rest of the script.

1 answer

✓ Accepted answer

Infinite Yield Possible means that whatever child your trying to wait for, doesn't exist. You might want to lookover everything to make sure you didn't make a typo. Please accept my answer if this helped!

2 comments

0

Ok I will check again but other than that would my script run correctly?

0

It looks fine to me

This discussion is preserved as it was. New answers, comments, and votes are closed.