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

What does print(part.Name) refer to and how should it be used?

function lightOnFire(part)
	print("Going to light this part on fire:")
	print(part.Name)
 
	fire = Instance.new("Fire")
	fire.Parent = part
end

	Workspace.FirePart.Touched:connect(lightOnFire)

I'm trying to figure out how print(part.Name) can be used in a script for future references. And what part.Name refer to?

Side question is what does the .Parent = part, do?

2 answers

✓ Accepted answer

print is a function that prints things to the Output window. So if you want to see the part's name in the output, you write print(part.Name)

print is super useful for debugging. For example, if you write print("test") but the word "test" doesn't show up in the output, it means that line of code never runs and the error is somewhere before it.

It does not, however, actually affect gameplay for anyone in your game.


Name is a property of everything. You can set the Name of an object to whatever you want in the Properties window. I use it all the time for organization purposes.

Like other properties, you can also access it with scripting. All part.Name references is the name that you set for the part.


Parent is also a property. In the Explorer, you'll notice that some things are "inside" other things, for example, a Part is in Workspace.

Whatever an object is "inside" is that object's Parent. So if a Part is in workspace, its parent is workspace.

The equal sign sets the property. So part.Parent = x will make the part's parent equal to x.

It actually makes sense that the property's name is "parent". Explorer has a similar layout to a family tree.

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