So I'm trying to learn a bit of object oriented programming and I couldn't find out how to do this: if I have a function in a table how can I stop it or remove it?
I tried doing this at first:
local a = {
b = function()
while wait(0.1) do
print('test')
end
end
}
a:b()
wait(2)
a.b = nil
but I found out that it wasn't working because it was stuck at the loop, so I did this:
local a = {
b = function()
while wait(0.1) do
print('test')
end
end
}
coroutine.resume(coroutine.create(function()
a:b()
end))
wait(2)
a.b = nil
but this didn't work too, so I have no idea what to do to remove or stop the function a.b

2 comments
Have you tried table.remove
Stopping a thread is totally different from removing a function from a table. table.remove has nothing to do with this.