BackStory
I always get annoyed when starting a new project then having a lot of variables to make. Takes some time and gets annoying over time. As a result, i decided to make this plugin. It wasn’t going to be at first but, i thought others may find this useful to them.
This is a neat idea. I’d certainly like @RuizuKun_Dev’s suggestion to use WaitForChild, and additionally I think an option to use double quotes rather than single quotes would be nice as I always use double quotes (I find them easier to read personally). It’d be really cool if this plugin created separation/comments between things, e.g. “Services”, “Modules”, “Assets”. Services would include all GetService calls, Assets would be all instances, and Modules would be all requires. Lastly, it’d be awesome to be able to prepend all of this to an existing script. I usually do this by having the user select the target script last and click a special button to prepend.
Additionally, I’m interested in a few things. Does this escape names so that quotes in the names won’t cause problems? Additionally, how are services handled? Is the ClassName checked against GetService or something?
Overall, I like this concept and it may be useful to me. Keep it up!
1.) I’ll most defiantly fix the problem with quotes in and Instances name.
2.) All Services that are used to put contain stuff are put into a table. Although, i was thinking of a better way of doing it and just adding all services instead of a select few.
3.No, it isn’t checked against GetService which i should do.
If there is anymore questions you have, feel free to ask them.
Usually what I do is first check if the instance is parented to game, and if it is, then I pcall game:GetService(instance.ClassName), and if it didn’t error, it’s gotta be a valid service. Also since 9 times out of 10 it’ll error, so normally this would slow down your script quite a bit due to how pcalls would return errors, but a recent luau update substantially improved performance when a pcall error, so I’m not worried about this anymore at this point not that it’s particularly a big deal in this case.
What I do to fix quotes is basically escape \, ", and ' characters using gsub. I tend not to use single quotes at all (just a habit/preference to use them I suppose haha) so I usually omit the last one there from my code, however, when I do usually it’s based off of the enclosing character if I know what it is already (e.g. ' doesn’t need to be escaped if the enclosing character is " and vice versa).