"Copy instance path" context menu option

game.StarterGui.Gui.AssetInfoFrame.Buy.FakeButton.Price is a whole lot to type out by hand, especially if you’re working at the command line to manipulate your instance.

This suggestion is basically an Instance:GetFullName() function that copies its return to your clipboard.

  • Yea
  • Nay

0 voters

What should happen is letting us drag the objects into the script editor; where it will automatically fill the path.

But you shouldn’t be referring to an object using it’s full name for every single thing you do. Why not have something like this?

local PlayerGui = Player.PlayerGui
	local Gui = StarterGui:WaitForChild("Gui")
		local MenuBar = Gui:WaitForChild("MenuBar")
		local Menus = Gui:WaitForChild("Menus")

and then refer to those variables instead of typing Player.PlayerGui (or script.Parent)

3 Likes

Usually, yes. But on occasion you only need to manipulate one or two objects deep in an instance tree, and there’s really no reason to define a variable for an instance if you only use it to access a single child instance.

If, in my above image, I were to modify both Label and Price, I would define a variable for FakeButton to make things easier. But I would not define variables for Gui, AssetInfoFrame, and so on.

1 Like

Unfortunately you can’t put this into studio yourself, but if you’re writing code you can write a function like this:

local function WaitForHierarchy(inst, str)
    local curr = inst
    local sects = { }
    str:gsub("()%.?([^\\%.]+)", function(a, b) 
        if str:sub(a-1,a) == "\\." then
            sects[#sects] = sects[#sects].."."..b
        else
            sects[#sects+1]=b
        end
    end)

    for i = 1, #sects do
        curr = curr:WaitForChild(sects[i])
    end

    return curr
end

-- Usage:
print(WaitForHeirarchy(script.Parent, "Frame.TextLabel.Shadow")) --> waits for Frame, TextLabel and Shadow
print(WaitForHeirarchy(script.Parent, "Frame\.WithDot.TextLabel.Shadow")) --> waits for Frame.WithDot, TextLabel and Shadow

That code was a pain to write for some reason :expressionless: I tried to overcomplicate it, but really it was simple.

2 Likes

This was a previous feature request that did not gain enough community support:

I feel like a more generally useful addition would be a function that enables plugins to copy a string to your clipboard.

2 Likes