#Please help! I'm having an issue with coroutines

1 messages · Page 1 of 1 (latest)

eternal finch
#

I've been able to get by on using Youtube videos and the Roblox dev page + my own brain to figure out most of the bugs ive been getting, but i have a Module script connected to a local script and i'm trying to run a coroutine.wrap to tell when a certain time has been passed and then function accordingly code Below

         local MissedCoroutine = coroutine.wrap(function()
        wait(.5)
        if Timer.Value > 2 then
            print("Missed")
            print(newBlockNode.Timer.value)
            HitPoint.Active = false
            TweenOuterRingToHitPoint:Cancel()
            newBlockNode.Visible = false
            DS:AddItem(newBlockNode, 2)
            coroutine.yield()
        end
    end) ()
    MissedCoroutine()

PS- sorry if it looks bad i'm pretty intermediate

frank halo
#
local MissedCoroutine = coroutine.wrap(function()
    wait(0.5)
    if Timer.Value > 2 then
        print("Missed")
        print(newBlockNode.Timer.Value)
        HitPoint.Active = false
        TweenOuterRingToHitPoint:Cancel()
        newBlockNode.Visible = false
        DS:AddItem(newBlockNode, 2)
        -- No need for coroutine.yield() here, since wrap() auto-handles it
    end
end)

MissedCoroutine()
#

@eternal finch try that

eternal finch
#

That worked much better thank you!