Adding onto Script.Source

I believe this is Script.Source, and not ScriptEditorService | Roblox Creator Documentation, however let’s say i generate a script, or already have a script that says Print("Hello Dev Forum!"). What if i wanted to add onto that. I wanted to add on another line, that for example says local Test = 9, so the whole thing would be:

Print("Hello Dev Forum!")
local Test = 9

i have no idea how you do it, and if it is ScriptEditorService | Roblox Creator Documentation, could someone explain it?

I think you would do something like:

script.Source = script.Source..--[[
   local Test = 9
]]--
local NewScript = "local Test = 9"

Script.Source..="\n"..NewScript
1 Like

Why did you do:

?

\n Creates a new line in the script

Okay, makes sense…

Would the script I provided work or does it just error?

It would error, it should look like this:

script.Source..=[[
   \nlocal Test = 9
]]

or

script.Source = Script.Source..[[
   \nlocal Test = 9
]]

(The \n is optional but i would recommend using it so you create a new line)

You should also include ; to prevent potential ambiguous syntaxes.
Example:

local a = b
(c or d)(e) --this would give off a warning because it could be interpreted as:
-- local a = b(c or d)(e)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.