It is simpler than it sounds: open the brick's properties, insert a Script object, then either paste your code into the script editor or drag the script onto the brick you want it to run in.
Make sure the brick is the one you actually want triggering the behaviour — scripts run in whatever object they are parented to.