It is too hard to edit multiline code in the command bar

Posting on behalf of @Amritss

As a Roblox developer, it is currently too hard to add pieces of code to be executed in the command bar that span longer than just a line. The command bar is usually used to just add small bits of code before runtime. However, sometimes some developers like myself do need to use code that is longer than just one line.

For example, this is a snippet of code that grants a player’s DataStore key the premium currency. The code is only 16 lines long. But when pasted into the command bar, it can be confusing to read and hard to manage, and requires you to scroll side-to-side to view the rest of it. While you can use the Run Script function for stuff like this, it is not convenient because it requires a separate .txt or .lua file. It’s quicker just to put it in the command bar.

This also creates an issue where if you mistyped something in the command bar, or there was a syntax error, you would have to scroll in the command bar using the arrow keys or mouse clicking which is not easily done.

Suggestions

Option A: Roblox could add a similar system to the current script editor we have, but you can press a button to run the script in the current context

Option B: A multiline scrollbar

If this issue is addressed, it would improve my development experience because it would be much easier to locate syntax errors and typos, and improve general editing in the command bar.

29 Likes

Thanks, really wanted this feature to get added. Now let’s hope it does.

2 Likes

For real, I want to make a plugin like InCommand from a while. A simple plugin like this but free could have such a positive influence on development. Hoping that one day a plugin like this will be available for everyone.

3 Likes

I rarely ever run snippets of code that are just 1 line in the command bar. The code I run I also usually type out by hand. Due to having to fit all the code on a single line it isn’t uncommon that I forget an end or a bracket here and there.

In the details below I’ve shared some of my most recent code snippets I used the command bar for. They are all multi-line snippets that could have benefited from a feature like this. I formatted them properly for this post to make the code actually readable.

click for code
-- this one was to preview VFX
local P = game.Selection:Get()
for i = 1, #P do
  P[i]:Emit(tonumber(P[i].Name))
end
-- this one was to check if RaycastParams are pass-by-value
local a = RaycastParams.new()
a.CollisionGroup = "DefaultOnly"
local b = a
b.CollisionGroup = "Default"
print(a.CollisionGroup)
-- this one was to test performance of value*value versus value^2
-- good luck trying to debug this one in the command bar
local value = 1.01
local t1 = 0
local t2 = 0
t1 = tick()
for i = 1, 100000 do
  value = value * value
end
t2 = tick() - t1
print(t2)
t1 = tick()
for j = 1, 100000 do
  value = value^2
end
t2 = tick() - t1
print(t2)
3 Likes

I have a discord channel full of multi-line command bar scripts. I frequently write mass-replace code which is multi-line. 99% of the time I use the command bar it is for a multi-line block of code.

1 Like

There are currently plans to expand the command bar into a mini script editor, which I imagine would include this. However, there is no timeline available for when that may be!

1 Like

we need this so badly; istg that I would pray to Big Brother Roblox if this feature were added

I’m a bit late to this conversation, but just wanted to inform you that a plugin like that but free already exists.

This feature would drastically help me in my development :pray: Please consider this Roblox.

1 Like

i’ll definitely try this out soon, does it support syntax highlighting and undoing/redoing script actions? like if i delete something will i be able to ctrl z it

By default it uses Roblox’s script editor so it should support syntax highlighting. Exestack uses ChangeHistoryService so it should support undoing/redoing but I haven’t tested this extensively. There might be edge cases where it doesn’t work.

Alright, when I get the plugin I’ll check it out. I just want one that uses undoing and redoing since Incommand doesn’t and it bugs me. By the way does it have that things where you can press tab to like quickly type something, like in the command bar you if i wanna type print i type “pr” and press tab and itll correct it to print? Incommand doesn’t have that either so it bothers me.

Yes, as I said earlier it uses Roblox’s script editor so (almost) anything that it has Exestack can use too., such as autocomplete and the ScriptEditorService API (so any plugin that uses it should work with Exestack). It’s free, so you should try it if you have any further questions on basic usage!

While you can use the Run Script function for stuff like this, it is not convenient because it requires a separate .txt or .lua file.

The reason you need another file is because if you update the module and try to run it again from the command bar, it has already been loaded so your changes won’t propagate. you would have to duplicate the module and delete the old one. you can automate this natively without plugins to make it more seamless. See here:

Screenshot 2024-10-30 at 10.08.37 AM

-- ServerScriptService/CmdRunner
local ActiveFolder = script.Active

local function Run(Parent)
	Parent = Parent or script.Commands
	local function run(commandName, ...)
		print("running cmd: ", commandName)
		local Script = Parent:WaitForChild(commandName, 1)
		local new
		if Script then
			new = Script:Clone()
			new.Parent = ActiveFolder
		end
		require(new)(...)
		new:Destroy()
	end
	return run
end

return Run

and i’ve added some example commands:

-- ServerStorage/CmdRunner/Commands/FileLoader
local StudioService = game:GetService("StudioService")

local function loadFile()
	local selected = StudioService:PromptImportFile({"txt"})

	if selected then
		print(selected:GetBinaryContents())
	else
		print("No file selected.")
	end
end

return loadFile
-- ServerScriptService/Modules/Hello
local function hello(str)
	str = str or "world"
	print("hello " .. str)
end
return hello

Then you can initialize them with this command in the command bar:

cmd = require(game.ServerStorage.CmdRunner); ssCmds = cmd(); sssCmds = cmd(game.ServerScriptService.Modules)

then use in the command bar like so:

ssCmds("FileLoader") -- will prompt you for a text file, then print the text
sssCmds("Hello") -- prints "hello world"
sssCmds("Hello", "Universe") --  prints "hello Universe"

You can create a new “CmdRunner” object for each command source parent. You don’t need duplicate modules for your command runner, you can initialize a CmdRunner for any of your module source folders natively.

it’s “hacky” but if you want to depend only on native studio then this is the only way to achieve what OP is asking. hopefully not too complicated. it’s flexible once you get used to it, but definitely can get messy if you aren’t careful with project structure.