I am making a plugin.
How do I write multiple lines of code in a script with the function
Script.Source = ""
I want to do something like
Script.Source = "print(Script.Parent.Name)
print(1)
print("String")"
but it shows an error.
Even doing it with an array shows an error.
How do I achieve this?
1 Like
Use a backslash ( \ ) to continue lines of code onto multiple lines.
Like this:
print("hello there \
i am cool")
2 Likes

Thanks it worked.
Is there a way to remove the extra spaces?
It doesn’t matter but it still bugs me 
Thank you
blokav
(blokav)
#4
Square brackets also work.
print([[hello
goodbye]])
6 Likes
You can just backspace them, it won’t change anything.
print("hello there \
i am cool")
works the same as
print("hello there \
i am cool")
I assume that’s what you meant. If I’m misinterpreting your question, let me know. 
1 Like
blokav
(blokav)
#6
That might be because the string you’re setting as the source has indents.
1 Like

it doesnt have any spaces here
@Polyheximal

The script which is being loaded has some extra spaces
Edit: My bad I forgot to save the changes in plugin thats why the spaces were there.
Thank you for your help 
2 Likes
sjr04
(uep)
#8
Blokav’s solutions would be way better here without worrying about escapes. Just saying
2 Likes
Additionally, \n can be used to create a new line.
Though, I endorse square brackets.
1 Like
Polyheximal
(Polyheximal)
#10
Perhaps it does, but a little extra effort won’t hurt if it means that your script will look cleaner. That’s just my opinion anyways.
Just want to say that if you want to make extra ultra sure that there is no problems with putting in the code just do something like this
Script.Source = [====[
print("magic")
local function test()
print([[yee]])
end
test()
]====]
1 Like