#Coroutines do not coroutine

24 messages · Page 1 of 1 (latest)

sudden agate
#
local PlayersService = game:GetService("Players")
local debounce = false
local debounce2 = false
local stopPoints = false

local taskCoro = coroutine.create(function(Time, stopPoints)
    while not stopPoints do
        task.wait(1)
        Time.Value += 1
    end
    coroutine.yield()
end)

ground.Touched:Connect(function(Hitbox)
    if not debounce then
        debounce = true

        stopPoints = false
        local Character = Hitbox.Parent
        local Player = PlayersService:GetPlayerFromCharacter(Character)
        local points = Player:WaitForChild("Data").Points
        local combo = Player:WaitForChild("Data").Combo
        local Time = Player:WaitForChild("Data").Time

        local success = coroutine.resume(taskCoro, Time, stopPoints)
        while not stopPoints do
            points.Value += combo.Value
            task.wait(0.08)
        end
        debounce = false
    end
end)

ground.TouchEnded:Connect(function(Hitbox)
    if not debounce2 then
        debounce2 = true

        ground.CanTouch = false
        stopPoints = true
        local Character = Hitbox.Parent
        local Player = PlayersService:GetPlayerFromCharacter(Character)
        local points = Player:WaitForChild("Data").Points
        local combo = Player:WaitForChild("Data").Combo
        for i = 0, 4, 1 do
            points.Value += combo.Value
            task.wait(0.08)
        end
        task.wait(1)
        ground.CanTouch = true
        debounce2 = false
    end
end)```
smoky gazelle
#

how to you know they dont work?

#

you made prints?

#

what is specifically not working?

violet oak
#

task.spawn() rizz

native ginkgo
sudden agate
#

ill get to the specifics

sudden agate
sudden agate
#

is it because it yeilds in the coroutine because the variable is ignored in the loop

sudden agate
sudden agate
native ginkgo
#

booleans are not referenced they are copied

sudden agate
#

oh i got it finally

#

aren is the goat

native ginkgo
#

oh thas great

sudden agate
#

ty

native ginkgo
#

I didnt help much, dont thank me lol

sudden agate
#

was thanking every1

violet oak
#

wtf

#

that was actually the solution

#

hell nah