What does script.parent mean?

Hey! So I wanted to do some tweening so I look up how do it the he wrote
local tween = GetService(“tweenservice”)
Local script = script.parent

So what does script.parent do does it activate the parent pls help fellow scripters thanks for your time

22 Likes

It is whatever the script is contained in, for example if it is in a tool, script.Parent would be the tool. You can read more information on this property here: Instance | Documentation - Roblox Creator Hub.

5 Likes

02f16e29e36705929a0ad688f4cf84f5

8 Likes

So, script.Parent gets the parent of the script which is what the script is in. Eg. if the script is in a part and you use script.Parent, it will state the parent of the script, which is the part or thing it in currently in
and PS.
To define it, do local variablename = script.Parent

I would recommend Alvin Blox if your new to scripting or TheDevKing for TweenService

ANDD…
when you get the “Parent” of the script, you can customize it using the variable you defined as it, but it changes depending on what the parent is.

7 Likes

Wdym? Why (30 characters)
Why …

I do watch the Dev king ,Alvin cofuses me

1 Like

when you type

script.Parent

It means it’s selecting the parent of the script.
For example. Say you have put the script inside a part. By doing script.Parent the script is refering to the part it’s in. Add another .Parent and it will refer to the parent of the part.

Let’s say we do the following;

local GamePlace = script.Parent.Parent

…then the script will select the workplace. Of course there’s a shortcut to this. Instead of doing script.Parent.Parent to select the workplace you can instead do workplace

I hope I helped.

13 Likes

But what if I inserted the script into a workspace not a part?

then the parent would be the workspace, please read my post it gives a comprehensive answer (also click on the link)

Sure, any type of scripter on youtube you can find or comfortable with.