So let me set the scene, I'm making a Gui that can affect the Workspace, but I'm not gonna know what the tree is to get to the thing from game, so I need to have it from where the script's origin is. Any idea how to help?
Current Code:
local LR = script.Parent.Parent.Parent.Parent.LegRest local button = script.Parent local function test() LR.Transparency = 0 LR.CanCollide = false end button.MouseButton1Click:Connect(test)
Tree: https://gyazo.com/ed50f7a0a4e6f5c08dba69af1c75c2d3
Thanks in advanced.
If you don't know how many levels deep you need to go in the ancestry of an object, and assuming you know the name of the object you're searching for, you can use either the :findFirstAncestor() method (if going up), or you could parse through a :getDescendants() array (if going down).
So in your case you could use
local LR = script:findFirstAncestor("LegRest")
I think that's what you're asking. Hope this helps.