So i’ve basically finished my pathfinding script, but it should probably be a module instead. i’ve tried to do this TWICE beforehand but on both occasions it never terminated (even after disconnecting everything and killing every loop) which is a huge issue because after you die maps are unloaded and once reloaded the pathfinding module throws an error when re-required because obviously its original variables aren’t accurate anymore. along with that, that means it will never get gc’d properly and so it would lead to a memory leak. i’m not 100% familiar with modules but i know how they work. i’ve used them a lot for this project (cough)
and i haven’t run into many issues (if any, aside from this)
I’d appreciate some help.
return should terminate the modulescript function as if it was a regular function
the issue is the fact it was structured weirdly, the return is at the end but a script would call a function called Initialize() which then started 2 loops, one for the pathfinding and one for raycasting, along with connections, however to solve that i had another function called Terminate() to end said loops and disconnect the functions but that didn’t fix the issue either? the script that initially required it was also destroyed afterwards, so there’s no good reason as to why it should keep running
Where you call your modulescript function, put it in a task.spawn() and then use task.cancel() to cancel the process
haven’t thought of that. i’ll try that but i have no idea if it’ll work
i’m crying that’s all it took thanks a lot
No problem! I just started trying to help people so It’s nice to have given out my first proper solution 