Embedded AppleScript error - Permissions issue?

EDIT: Hey Mr. Noodle, turns out it was a permissions issue. I toggled "Full Disk Access" OFF/ON and now it is working as intended. Feel free to delete this post or leave it here for others to find in case they run into a similar issue. Thanks!
- - - - - - - - - - - - - - - - - -
Hey Mr. Noodle I am getting an "error executing Applescript on file" when trying to run an embedded AppleScript - BUT it actually ran just now as I was writting this post, albeit only once! MacOS suddenly prompted me for permission for hazel to edit the file, and it ran fine that time - but only that time! Now it's back to giving me the error. I checked and Hazel has "Full Disk Access" so not sure what is happening here. Including the script just so you know:
`
tell Application "Finder"
display dialog "Enter a new name for the file or folder:" default answer ""
set FolderName to text returned of result
set name of theFile to FolderName
end tell
`
Thank you
- - - - - - - - - - - - - - - - - -
Hey Mr. Noodle I am getting an "error executing Applescript on file" when trying to run an embedded AppleScript - BUT it actually ran just now as I was writting this post, albeit only once! MacOS suddenly prompted me for permission for hazel to edit the file, and it ran fine that time - but only that time! Now it's back to giving me the error. I checked and Hazel has "Full Disk Access" so not sure what is happening here. Including the script just so you know:
`
tell Application "Finder"
display dialog "Enter a new name for the file or folder:" default answer ""
set FolderName to text returned of result
set name of theFile to FolderName
end tell
`
Thank you