I am calling function from action of entity and this function has loop with wait() in it. If I just do this, then the action and that function are running in parallel.

Is there a way for action not to proceed until function completes?