Just to flesh out the previous answer. I'm guessing you, like me, have a python background where this sort of thing is valid. In gdscript, think of the script you're writing as being within a class.
Outside a method, all you can do is declare member variables which have a wide scope. Everything else goes within methods. The convention is to put tool, then extends, then member variables, then methods. In this case, it could look something like this:
tool
extends Sprite
func make_noise():
var noise = OpenSimplexNoise.new()
noise.seed = randi()
noise.octaves = 4
noise.period = 20.0
noise.persistence = 0.8
# Sample
print("Values:")
print(noise.get_noise_2d(1.0, 1.0))
print(noise.get_noise_3d(0.5, 3.0, 15.0))
print(noise.get_noise_4d(0.5, 1.9, 4.7, 0.0))
func _ready():
make_noise()
set_notify_transform(true)
func _notification(what):
if what == NOTIFICATION_TRANSFORM_CHANGED:
get_material().set_shader_param("scale", scale)
Take a moment to read this intro in the docs to get yourself up to speed on the essentials:
https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html