Any way to get all references to an instance?


Basically the title, I was wondering if there was a way to get all references to a specific instance in terms of if that specific instance is the property of another instance?

Say I have an ObjectValue whose value is a model. Without knowing the ObjectValue exists, and knowing the model exists, is there a way to get the ObjectValue referencing the model? I looked around on the documentation of Instance but it doesn’t seem to have any method that does this, I might be looking past a service or didn’t see the function.

I’m basically asking if a built-in method exists, if not, I will use CollectionService and GUIDs.

local function findReferencesToInstance(instance)
	local instanceReferences = {}
	for _, descendant in ipairs(game:GetDescendants()) do
		if descendant:IsA("ObjectValue") then
			if descendant.Value then
				if descendant.Value == instance then
					table.insert(instanceReferences, descendant)
	return instanceReferences

I don’t believe so, here’s a function which essentially achieves what you’re trying to accomplish.

1 Like