Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 8 years ago
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

Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
8 years ago

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.

Ad
Log in to vote
0
Answered by 8 years ago

it prints the name of the part

Answer this question