New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

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

Asked by 3 years ago
function lightOnFire(part)
    print("Going to light this part on fire:")

    fire ="Fire")
    fire.Parent = part


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
Answered by
Perci1 4928 Trusted Moderation Voter Community Moderator
3 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.

Log in to vote
Answered by 3 years ago

it prints the name of the part

Answer this question