What is Script.Parent for in Lua?
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.
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.
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
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