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

What does script.Parent.Parent.Parent mean? I have a trouble with understanding this code

Asked by
Roox4 21
7 years ago

For example:

local part = script.Parent.Parent.Parent.Part

I've seen a code with this and when I tried to remove Parent.Parent so it was just script.Parent.Part it just didn't work. Then i knew that it needs to be there but I don't know why. So can someone explain me why there are multiple Parents?

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
7 years ago

By itself, script.Parent is equivalent to the instance that the script is inside of. However, for example, if the script was inside a part that was inside of workspace, you can go script.Parent.Parent to get the workspace. If there was a part inside workspace called Part, you could then go script.Parent.Parent.Part to get the part.

Essentially, all your code is doing is getting the parent of the parent of the parent of the script, and then getting the part inside of it.

0
Thank you so much! Roox4 21 — 7y
Ad

Answer this question