XF 2.0 Error With Attachments After Upgrade

After upgrading to Xenforo 2.0, several users are getting this error when they try to upload attachments in a thread.

ErrorException: [E_WARNING] fopen(/domain/directory/internal_data/attachments/079/986-123456h7fvb56nm8o9.data): failed to open stream: Permission denied in src/vendor/league/flysystem/src/Adapter/Local.php at line 151

What might cause this to happen? Thank you!
I did that, but I'm still getting the error. The error doesn't always come up, it seems to go back and forth. Sometimes the error comes up during an attachment upload, and other times the attachment upload will work correctly. What else can I try to correct this?
Quick additional question: Is there anything in the new Xenforo 2 version that would cause this error to occur more frequently if the directories were not CHMODed correctly than on Xenforo 1? The reason I ask is I'm wondering if there is something on the server that is changing the permissions occasionally. I ran a script again to do what you said above, and that temporarily fixed the issue. But I had run the script earlier too and the problem came back a few days later. The server setup is the same as on the previous version, and we didn't have this problem on Xenforo 1. So, if the server does change permissions occasionally, is it possible that we wouldn't have gotten the error on the old version anyway but we would now get the error on the new version of Xenforo? Or is there likely something totally different at fault, nothing to do with the permissions of those two directories?