Servant - Insert services into your scripts quickly!

Servant is a very small plugin that adds a new method of inserting services into your scripts. Using this plugin, you can set a shortcut that will open a popup to insert a service at the beginning of your script. Typing the service name into the text box and pressing the Enter key (or OK button) will insert a new variable at the top of the script referencing this service.

How to use

After installing, you will need to define a shortcut to open the popup. This can be done by navigating to File > Advanced > Customize Shortcuts. From there, search for “service” and locate the plugin. In my case, I’ve assigned Ctrl + R as the shortcut to open the window.

After that, pressing your previously assigned shortcut while in a script will display the insert popup. Entering a service name into the text box will show an autocomplete result for the closest match to your input:

image

Pressing the Tab key will fill this autocomplete result. Pressing Enter or the OK button will insert the service at the beginning of the script and close the popup. If you enter an invalid service, it will inform you the service doesn’t exist and you will need to re-enter it.

image

Required permissions

This plugin sends an HTTP GET request when Studio starts to obtain the latest Roblox API dump. This is used to ensure the service name you’re entering is valid, as well as for autocompletion. The plugin does not require you to give it this permission, but these features will not work if disabled.

It also requires the script injection permission, for fairly obvious reasons (it needs to insert text into the script you’re editing).

Limitations/issues

Currently, there are three issues regarding this tool that (as far as I am aware) are a result of Roblox limitations:

  • Popup is not focused when text box is focused, requiring the user to click in the text area to type. This was reported back in May in this bug report.
  • Undo support is not available. ChangeHistoryService does not support changes to a script’s source (as listed here), and the workaround offered will not work for this purpose as it would interrupt the script that is currently opened by deleting and re-inserting a new one.
  • Scroll position resets to the top when services are inserted. Studio will reset your cursor position to the beginning whenever a script’s source is modifed externally. There was a feature request made to address this all the way back in 2017.

If anyone has suggestions on how to get around these issues, feel free to mention them!
Hope you find this plugin useful!

26 Likes

I like the idea, would help alot off new people like myself get started on scripting, Very nice tool/plugin

2 Likes

I don’t think this would be very useful in practice but a pretty interesting plugin nonetheless.
Nice job :+1:

3 Likes

Thanks! The intended use for this was being able to insert services into larger scripts (for example, trying to bind something to ContextActionService near the bottom of your script, you could use this to insert the service without going up and moving back down), although unfortunately that didn’t pan out since there’s no real way to reset the cursor position after the source is edited at the moment. Hoping functionality like that gets added soon.

1 Like

Nice idea! While you can’t directly set the cursor position you can set the line it’s on. You could set it to the next line after the service import statement.

1 Like

What if I want to insert a service’s code snippet at a specific line of the script? Will that work or does it just concatenate the code at the start of Script.Source. Is it possible to append the script using this plugin?

There is no way of getting the current line number or cursor position in a script, unfortunately. You can open a script at a specific line number, but with no way of knowing where the user was at before, it’s not much of a help in this case. That is partially what the feature request I linked in the original post was suggesting/trying to address.

I don’t think it’s possible to get the current cursor position.

Yeah I just got to know, anyways nice plugin :cool: