I have a function which is supposed to run once for each player who touches something. I have set it up so that, in theory, it should work. However, it runs twice per player instead of once. I suspect this is because the touched function runs multiple times in such quick succession that the check which is supposed to prevent it from running more than once per character fails due to two threads running at almost exactly the same time. Is there any way to prevent a new thread of a function from starting when there’s already one in progress?
In lua, only one thread can be running at once, so the function can not start running in another thread before finishing in the first unless the function yields. Is there a wait in the function and how are you trying to make sure that it only runs once per character?
1 Like
If that’s true, the problem isn’t what I thought. There’s probably a mistake in the code. I’ll check again.
Thanks for your help. I was able to identify the problem.
1 Like