What you described: "I created a script that finds the students based on the information in the "class" field, " sounds like exactly what you should do and it should work. Since it didn't, you'll need to describe this script and your layout in greater detail so we can determine why it didn't work.
Generally speaking, if your layout is based on the table on which you are performing the find, then performing the find should pull up the students you need to print out as your "roster".
The structure of your database could be the issue here as what you describe typically requires a many to many relationship as a given class can list multiple students and students take multiple classes (unless this is elementary school or a similar set up with one class to each student.)
It sounds like you have the script, but need a way to make the script run when you go to the layout. I assume you are looking at a layout where you have the class info, then change to the student list layout to see the students that are in that class. You could incorporate your script into a button that takes you to the student layout by setting a variable to hold the class info, go to the student layout, then perform your find using the variable for the class info find critera.
If you do have the many to many relationship as Phil described, you could set up another layout for the class with a portal to students listing all students in that class. This would avoid having to perform a find or have a script.