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

What does this built in function script do?( Involves Variables and Built in Functions)

part = script.Parent

part.Touched:connect(function() local awesomePart = game.Lighting.AwesomePart:Clone() awesomePart.Parent = game.Workspace

end)

I don't understand it

1 comment

1

Which part do you not understand in this code?

2 answers

✓ Accepted answer

It clones the part when you touch the part and makes the parent of the cloned part Workspace.

part = script.Parent --This defines the parent of the script, which is the part.

part.Touched:connect(function()  --When the part has been touched by any other object, the function will execute.
	local awesomePart = game.Lighting.AwesomePart:Clone() --This will create a copy of a part from Lighting called AwesomePart
	awesomePart.Parent = game.Workspace --Moves the AwesomePart clone to the physical world
end)

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