ObjectValue Script

  1. What do you want to achieve? Keep it simple and clear!

I want a function that checks if there’s a objectValue inside a specified instance, if true then
change the specified instance parent to the objectValue Value.

  1. What is the issue? Include screenshots / videos if possible!

I tried it with an Module:

local ZIP = {}

function ZIP.ChangeParent(instance)
	
	local Path = instance:FindFirstChild("ZIPPATHVALUE")
	if Path then
		instance.Parent = Path.Value
		return true
	else
		return nil
	end
	
end
function ZIP.Unpack(Folder)
	for i,v in pairs(Folder:GetChildren()) do
		print(ZIP.ChangeParent(v))
	end
end
return ZIP

and activated it in the command bar:

zip = require(game.ServerStorage.RoZip.ZIPModule)
zip.ChangeParent(workspace.dev.ZIP.putinlighting)

and it gave me an error:

Attempt to set parent of Workspace.dev.ZIP.putinlighting to Workspace.dev.ZIP.putinlighting.ZIPPATHVALUE would result in circular reference - Edit - ZIPModule:7

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I looked on Developer hub and nothing…

So I want help to remove the error or a new script…

is Value an instance?

if it isn’t then you can’t parent an instance to a value property

1 Like

The ZIPPATHVALUE is an objectValue and the value is workspace.Lighting

You can parent it if the Value is of type object.

You can’t set a child’s parent as itself. Or a parent’s parent as a child.

This is called a circular reference as the parent’s children contains it’s parent.

1 Like

It’s because you’re trying to set the parent to one of its descendants. Path.Value is likely a descendant of instance.