#I am not able to close a coroutine that is inside itself

1 messages · Page 1 of 1 (latest)

mild veldt
#

results in a "cannot close normal coroutine" error

cobalt shuttle
mild veldt
cobalt shuttle
#

i don't quite get it, do you plan on adding more coroutines inside Move.Clear?

#

otherwise why don't you just close it like coroutine.close(Move.Clear.Timer)
not quite sure about the error, but for loops and arrays sometimes suck together

#

does the EntityFunctions.ForceEnd thingy affect anything about Move.Clear?

formal auroraBOT
#

studio** You are now Level 1! **studio

mild veldt
#

it's a move system, the Move table is

#

normally the Move.Clear table is automatically cleared when the move has ended

#

but

#

since this is a toggle based move

#

it doesn't do that, and everything inside Move.Clear stays the same, so the coroutine from the if statement above

#

is the same inside that loop/Move.Clear.Timer

cobalt shuttle
#

try .wrap instead of create, i remember using create and then switching to wrap many times, or even better task.spawn
it works really similarly: you create with task.spawn (returns thread)
and end it with task.cancel(thread)

mild veldt
#

i tried this with task.spawn same issue

#

i'll try again hold on

#

"cannot cancel thread"

#

is the error i get

cobalt shuttle
#

are you 100% sure Move.Clear.Timer isn't nil by the way?

#

oh wait

#

i think i got it

mild veldt
#

i'm 100% sure

cobalt shuttle
#

you're trying to cancel a thread that is already canceled

mild veldt
cobalt shuttle
#

like i don't think you even need to save it, you can just do:
task.spawn(function() task wait and other stuff...
and no need to cancel

mild veldt
#

or how would i check

mild veldt
#

okay os

cobalt shuttle
mild veldt
#

you can hold down the parry right, and unhold it

#

like a block

#

basically just a block

#

but the reason why i have task.spawn is so that

cobalt shuttle
mild veldt
#

when you hold it for too long

#

it's going to automatically end

#

that's what force-end function does

#

lemme make a little

#

drawing i guess

cobalt shuttle
#

sorry i was afk

cobalt shuttle
mild veldt
#

like this

#

it starts at the move function

#

you're not parrying

cobalt shuttle
# mild veldt

by the way, there's no really need of "elseif Parrying", just "else" (unless you plan to check for more conditions)

mild veldt
#

but

cobalt shuttle
mild veldt
#

anyways when you hold F

#

it will go to the not parrying statement and will make a new thread

#

if you stop holding F before 1 second is up

#

it will automatically cancel that thread

cobalt shuttle
#

uhhhhhh

mild veldt
#

but it's inside of it

cobalt shuttle
#

try debugging with some prints, just to make sure everything else works and nothing is nil

mild veldt
#

the force end just recalls the move function, and because you're already parrying it stops parrying and cancels the thread

#

it does

#

i've already checked if things were nil

mild veldt
#

i will try coroutine.wrap though

#

i don't think it will work

cobalt shuttle
#

probably something obvious tbh

mild veldt
#

well

cobalt shuttle
#

i feel like i've seen this error before, but if you're 100% sure the timer thing isn't nil, no idea

mild veldt
#

you can't normally cancel a thread inside itself

mild veldt
cobalt shuttle
formal auroraBOT
#

studio** You are now Level 2! **studio

cobalt shuttle
#

no clue

cobalt shuttle
mild veldt
smoky coral
#

yes

cobalt shuttle
#

you can use timers with runservice even if it's pretty ugly

mild veldt
#

like i guess i could

#

make an implementation it wouldnt be crazy hard but i wondered if

#

anyone had a fix to this

#

because if there is a fix it's just really easy and simple

cobalt shuttle
#

it's not that hard, just create a timer, increment it, check its value...

#

yeah i agree

mild veldt
mild veldt
#

i just don't really want to if there's some easy fix

cobalt shuttle
#

the truth is lua kinda sucks, and luau isn't much better, there are alot of painful things like this