For example:
I have 2 actions binded by ContextActionService. Normaly, if an action is triggered, then another action can’t be triggered. However, player can bypass this by press the keys of 2 actions in the same time. And the actions need to reaction fast , So I can’t using some check that will make action performance too lag. How to fix this?
Do you mean like a debounce? A Boolean-controlled action thing should work, the code will execute in under 0.02 seconds, I don’t know about the key presses. So, a Boolean system is what I would recommend.
In this case, boolean doesn’t work, because both of the actions are triggered at the almost same time, so the boolean checks are performed at the same time. Since the flag boolean will be sat after the boolean check and actions are check the boolean at the same time, so
both of checks will pass and boolean didn’t work.
I just didn’t know if there was enough time between the key presses, how close to the exact same time they were pressed. I guess you couod try unbinding and rebinding the actions from the other actions, but that’d be slower than the Boolean method.
I don’t think there’s another way (at least notnthat i know of)
Well, player can easily trigger 2 actions in exactly 1ms. However, I got the solution. I found that lua won’t create a new thread when calling the meta method. By another word, lua will calling the function of meta methods one by one. So from this way, the race condition is easily be avoided
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.