I have made a naive attempt to create a module that displays an instance’s complete reference starting from game
as in game.workspace.part
only if it is a descendant of the workspace, but my method returns an error telling me I’m indexing nil.
Here is my attempt :
local CustomFunction = {}
function CustomFunction.Index(item)
if not item then
return "item parameter was not specified" end
local found
local ref = tostring(item)
for _, item in ipairs(workspace:GetDescendants()) do
if item.Name == ref then
found = item
end
if found.Parent == workspace then
return "game.workspace."..found.Name end
repeat
found = found.Parent
ref = found.Name.."."..ref
until found.Parent == workspace
end
return "game."..ref end
return CustomFunction
What am I doing wrong, can anyone tell me please?
local CustomFunctions = require(script.Parent.CustomFunctions)
print(CustomFunctions.Index("part") )
-----> attempt to index nil with 'Parent'
Edit : I find it mortifying to say I did not know what the :GetFullName
function is