Need help writing a script for Jira

I need help writing a script for Jira that when you enter a username and a role it will check for which projects the user is assigned to that role. I am quite new to Jira so thank you for the help in advance.

Also, examples of similar scripts would be quite helpful as well. Thanks.

Did you ever figure this out? Happy to help if you still want it. Scriptrunner, right?

Works flawlessly with the Script Runner, thank you ^^