Code Templates - Easily Apply Templates to Your Scripts

Code Templates is a plugin that allows scripters to quickly reuse templates without having to copy and paste between other scripts.



  • Name, Roblox Username, and current date replacements
  • Can be applied with --$TemplateName in scripts or with CollectionService tags
  • UI changes based on theme


Create new templates with the “+ Add” button


Add tags to be replaced dynamically

Using the tags $NAME$, $ROBLOXSTUDIOUSERNAME$, and $CURRENTDATE$ in your template replaces them when using them within a script.

Add templates when inserting scripts using CollectionService tags

Adding a CollectionService tag to any instance that has the same name as a code template will cause any children inserted to get the code template.

Note: This only applies to direct children

Apply a template in a script with --$TemplateName

Typing --$TemplateName in a script where TemplateName is the name of a template you have will replace it with the template.


:warning: Notice:
In Team Create you will need to commit the script when using this feature for the changes to apply.

Import Codes

Use these codes by right clicking the add button, selecting import, and pasting one of the below codes.




Great! it tooks a while to give the credits. :smiley:

1 Like

Infinite name thing:
For example, the name of the script is called “Testing”
and you put --$Testing script$ at the top, it continuously adds to the script, and it should clear the script and add the template instead of adding it onto the script, or have it be toggleable.
Edit: other than that this is really useful.

1 Like

I designed it so that it doesn’t clear the script when inserting a template. With this you have more options on what to do. You can either select everything and replace it with --$TemplateName or you could add it somewhere else in a script like this.


It would be nice to have a clearing a setting that you set like in the script you will put in the script that you put the template in, did that make sense? I’ve got no clue.


I’ll implement a way to change this behavior in a future update.

1 Like

I have released a new update that adds this functionality. Using --$TemplateName will continue using the old way, while --$$TemplateName will replace the entire script.

1 Like

Nice, and a good way of implementing it.

1 Like

Oh. I went through this before and didn’t realize how actually useful this is for module building. This is such a good resource, thanks I’ll be sure to try it :), are there any already existing templates?

1 Like

Does this plugin correctly handle the case where someone writes --$TemplateName in a string? e.g print("--$TemplateName") ?


This cannot happen as far as I know. is a comment in Lua, which is ignored, so that is the same as doing print(“.

1 Like

Sorry, I think I gave a bad example. What about a case like:

idk why someone would do this but they probably will
1 Like

I don’t think this is handled correctly currently. I might fix this in an update sometime, but it’s not a priority right now because it seems like something that will never happen.


The plugin does not come with any templates built in. I will add an export and import feature in the future for sharing templates.

Templates are pretty easy to make. Here’s one I use for a class.


I’m not familiar with import codes. What tool is this for and what does it do?


In a future version of Code Templates I plan to add a way to export templates that you’ve created to share with other users. Right now you can only import templates. The import codes can be used by right clicking “+ Add” and selecting import. For example, by using the Knit import code some Knit tenplates are added (KnitService, KnitController, and KnitComponent).

1 Like

This is awesome! Great contribution.

1 Like

Hate to bump this, but is there any updates done on this? This seems really useful and I would love to see a way to export our own templates.

1 Like

I’ve been working on an update for this plugin to add lots of new features, but it’s currently blocked by some things outside my control.

1 Like

Oh dang! Well hopefully these said restrictions are eased, thanks for responding either way!

1 Like