Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i put multiline code in script.Source, how do i do so?

I'm trying to make a plugin, I want it to create a script with the following code:

local Brick = script.Parent


local function PlayerTouched(Part)
	local Parent = Part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		Parent.Humanoid.Health = Parent.Humanoid.Health - 100 --damage
	end
end

Brick.Touched:connect(PlayerTouched)

Altho it wont work:

local Somescript = Instance.new("Script")
Somescript.Source = "local Brick = script.Parent


local function PlayerTouched(Part)
	local Parent = Part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		Parent.Humanoid.Health = Parent.Humanoid.Health - 100 --damage
	end
end

Brick.Touched:connect(PlayerTouched)"

I can only write

local Somescript = Instance.new("Script")
Somescript.Source = "local Brick = script.Parent local function PlayerTouched(Part)... "

Plz help! :(

1 comment

0

lol you put a " before local on line 2

1 answer

To do multi-line codes using Script.Source you have to use [[ ]]

print([[This
Will
Print
In
Multiple
Lines]])

You can also use these in multi-lined comments.

--[[
This
All
Will
Be
Commented
Out
]]--

print([[
This is 
not commented 
out]])

Hope this helped! Feel free to select this as an answer if this worked for you!

This discussion is preserved as it was. New answers, comments, and votes are closed.