Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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.

0
Probably because there isn't anything named "Gamepass" under Gamepass. XAXA 1569 — 6y
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. GoldenPhysics 474 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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!

0
Ok I will check again but other than that would my script run correctly? duckyo011 36 — 6y
0
It looks fine to me PyccknnXakep 1225 — 6y
Ad

Answer this question