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

What does script.Parent mean?

Asked by 10 years ago

This may seem like a stupid question, but I have created my own scripts but I could never figure out what script.Parent meant. I see it everywhere, so can someone tell me what it actually means?

3 answers

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Parent is a property of any ROBLOX object.

Thus (when names are not repeated)

blah.Parent[blah.Name] == blah

That is, blah is a child of blah.Parent. This is shown in the explorer by the object being tabbed in to the right, and collapsible into the [+].

script is a built in reference to the Script object which is currently executing. So if you inserted your script into a part, that part would be script.Parent (since the Script object's parent is that part).

0
Thanks! Octillerysnacker 115 — 10y
Ad
Log in to vote
0
Answered by
TofuBytes 500 Moderation Voter
10 years ago

script.Parent is anything in the same area/directory the script is located in. Here's an image on what the parents are just in-case you need more info. script.Parent

Log in to vote
0
Answered by
TaslemGuy 211 Moderation Voter
10 years ago

To understand what it means, you need to understand the explorer.

Here's a picture of a hypothetical explorer window.

The objects in the explorer are arranged in what's called a "tree." Each object is inside of another.

Here we've got a couple objects. We have the model named Car that contains six objects: four parts named Wheel another part called Base and a script named Drive.

The Parent of each wheel and the script is Car. The parent of Car is Workspace.

Inside of the Drive script, if you write:

print( script.Name )

Then the word Drive will be printed. script refers to the current script object. So the Parent of the script will be, in this case, the model Car. So if we say:

print( script.Parent.Name) 

The word Car will be printed, since Drive has the parent Car.

If you wanted to access the base and make it transparent, for instance, you could say the following:

script.Parent.Base.Transparency = 0.5

Because Base is a "child" (the opposite of "parent") of the Car model, you can get it from the model script.Parent by adding .Base.

So you use the script reference when you want to talk about things relative to the script in the explorer.

Answer this question