Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I change the text of a script with a plugin?

Asked by 9 years ago

I develop plugins, and one of the ideas I like the most is the ability to change a default script text into something else. However, I have no idea how to accomplish this.

0
I don't know how you'd do this with a plugin, but there is an area in Settings that allows you to change the font. Perci1 4988 — 9y
0
So do you want to change the actual source of the script, or just the font etc.? There might be some APIs for the latter. juzzbyXfalcon 155 — 9y

1 answer

Log in to vote
2
Answered by 9 years ago

Assuming it's the Source of the script you wish to edit, not the actual font of the script-editor.

You can edit the Source of a script by accessing it through the Source-property (script.Source). It's important to note that regular scripts do not have the security clearance to set .Source anymore, but plugins (and commandline(?)) do.

I assume you want to replace the default "Hello world!"-print, so I made an example of how you could achieve that.


mySource = "-- This script was edited with ChipioIndustries' plugin. " replaceTemplate = [[print 'Hello world!'\n]] -- This is the default template. -- Adding a ChildAdded-event to ServerScriptService, so this can be applied to all newly created children (or newly re-parented) game:GetService("ServerScriptService").ChildAdded:connect(function(child) if child:IsA("BaseScript") or child:IsA("ModuleScript") then -- Makes sure it's a script if child.Source == replaceTemplate then -- Checks if source matches template child.Source = mySource -- replaces source. end end end)

HOWEVER, if you did mean to edit the font, you can take use of settings(). I'll post back with results if I find anything further.

0
No, I didn't mean the font. Thanks a ton! ChipioIndustries 454 — 9y
Ad

Answer this question