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

Why is coroutine.yield not yielding?

                local HurtPlayer = coroutine.create(function()
                    local Death = math.random(1,2)
                    while true do
                        wait(1.5)
                        -- stuff
                        if Death == 1 then
                            if playerTable[randomPlayer].Character.Humanoid.Health <= 10  then
                                coroutine.yield()
                            end
                        end
                        playerTable[randomPlayer].Character.Humanoid.Died:Connect(function()
                            print('Humanoid Died')
                            coroutine.yield()
                        end)
                    end
                end)

I've tried disconnecting, breaking, returning, etc and I can't find a solution. It's inside of the coroutine but it won't yield.

1 answer

I figured it out, I only needed to use a boolean and an if statement to yield it.

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