Script Structure Advice for Obby Game (One Script vs Multiple)

Hello! I’m working on an obby game and wondering whether it’s better to combine all scripts related to map interactions into a single script, or keep separate scripts for each stage. What’s the best practice in terms of performance and organization? And I’ll just keep scripts like the checkpointHandler separate from the others, as well as other unrelated scripts.

CollectionService is perfect for obbies.

For killbricks: Give each killbrick a tag, like “Killbrick.” Then, in ServerScriptService, make a script for killbricks. Inside it, you’ll want to use CollectionService:GetTagged to get every instance tagged with “Killbrick.” Then apply the killbrick logic from there.

For checkpoints: Similar deal, however this time you have two options. You can either put the checkpoint number as the name of the checkpoint instance and use CollectionService like you did for killbricks. Or, you can use attributes. Attributes are like tags but they store values, too. You can’t use CollectionService with them (unless you create a tag with the same name as the attribute), but you can put all the checkpoints into a single folder and then use :GetChildren in the same way you used CollectionService:GetTagged for killbricks.

Each script is a thread of itself

Using tags or folder is better for organization and initiating them through single script

It depends on the specifics, but anything you intend to reuse a ton should either be a single script giving behaviors to tagged items, or a module if the functionality needs to be usable by another script elsewhere.

If you have some unique per stage behavior or some item that is unique that combines parts of module scripts or something, that should be its own script instead of combined with unrelated things.