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

What is Script.Parent for?

Asked by 10 years ago


What is Script.Parent for in Lua?

4 answers

Log in to vote
0
Answered by 10 years ago

script.Parent is when the script gets its parent AKA what the script is inside. .Parent is something you use to get the ascendant or what the object is within script is the actual script itself. Like saying..

print(script.Name)

Say you had

Game.Workspace.Model.Part.Script

If you put down in the script

script.Parent

That is the object the script is inside. So this would go to Part

Say if you said..

script.Parent.Parent --would go to model
script.Parent.Parent.Parent --would go to workspace
script.Parent.Parent.Parent.Parent --would go to game

Also to verify that you have the right ascendant you could put down

print(script.Parent) --part

Hope this helped.

Ad
Log in to vote
0
Answered by 10 years ago

It's script.Parent, not Script.Parent (btw)

script.Parent is used for functions, you use it to print the parent of the script.

For example, script.Parent can be used for GUI's. A Gui is the parent of the script.

You can also use script.Parent for other things then functions. That's just an example.

0
Do you have a link where I can read up on this? DarkArtistReborn 5 — 10y
Log in to vote
0
Answered by 10 years ago

script.Parent is used for indexing the script 'parent,' or the object in which the script is under.

If your heiarchy is:

 - Workspace
    - Part
        - Script

script.Parent would equal to game.Workspace.Part

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

script.Parent is used for getting the script's Parent. If you have a script inside of a part then the script.Parent would be that part. It's just saying the parent of the code, nothing special(:

EXAMPLE;

p = Instance.new("Part",game.Workspace)
script = Instance.new("Script",p)
print("The Parent of the Script is: "..script.Parent)

The Parent of the Script is: Part

Hope I Helped

+1

Answer this question