You can use the Adaptavist Library to explore scripts, specifically all Cloud scripts, and you can refer to the many code snippets that are available.

Remember there are API differences between Jira Server and Jira Cloud. ScriptRunner for Jira Cloud utilises only the REST API and not the Java API