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?
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.