Plugin to remove comments from scripts?

Anyone has a plugin which can remove comments from scripts? I kind of needed one right now.
I have a lot of unnecessary comments in some code I have, and I wanna also do some reorganizing and make it less spammy and repeated, and I wanna re-do comments and everything to better organize it. Anyone knows a plugin like that? (even a console command would help)

2 Likes

I mean, I don’t think there is one. I don’t think it’s even possible to alter your code with code, that’d be a huge security flaw with exploiters. I recommend just clicking ctrl + f, then type in “–” to find all notes in your scripts.

You can select your script and run this in the command line. If you really care enough I can make it a plugin, but It’s late and I’m lazy. Make sure to backup your script first. I’m fairly certain that this won’t mess your script up, but I can’t even read this anymore and it’s best to play it safe.

game.Selection:Get()[1].Source = game.Selection:Get()[1].Source:gsub("\n%-%-[^%[].-\n","\n"):gsub("\n%-%-%[%[.-%]%]\n","\n"):gsub("\n(.-)%s*%-%-%[%[.-%]%]%s*(.-)%\n","\n%1 %2\n"):gsub("\n(.-)%-%-[^%[].-\n","\n%1\n")

I think it’s clear that I’m no expert on string patterns, but I make things work. It doesn’t delete multiline comments for some reason, and again if that’s something you really want feel free to DM me and I’ll work on it tomorrow night if nobody beats me to it.

6 Likes

It is possible. Scripts cannot be edited from within the game but they are editable through the use of the command bar and plugins. ScriptDocument:EditTextAsync() can be used to change the text of said scripts. So Can Script.Source as Shown Above

Script.Source is often used for Editing the whole script document while ScriptDocument:EditTextAsync() is Often used for Editing Sections of it.

As far as I know at least.

lmao this is an old post

yeah this is very much doable i was relatively stupid when it came to programming a the time

Makes sense ye, we all have our beginnings. You’re fine.