Can i change objects parent using object value?

Hi,
Quick question can i change parent of an object if im accessing object from object value?

1 Like

No values won’t work it will say something like
Error line1: parent is not a child of Value

1 Like

Yes you can. An ObjectValue holds a reference to an instance, so accessing the value retrieves a reference to that instance. Value.Parent is valid for an ObjectValue. @crunchbone Please test and do some research before replying!

local Part = Instance.new("Part")
local ObjectValue = Instance.new("ObjectValue")

ObjectValue.Value = Part -- Value is now a reference to part
ObjectValue.Value.Parent = workspace
7 Likes

thanks! also can i access a childrens of the part using objectvalue?

Yes.

The ObjectValue itself is still a ValueObject like any other, so you can keep references to it… If you access the Value however, you’re now creating a reference to the same instance that ObjectValue is holding a reference to.

Say for example your ObjectValue’s Value was a Player character. Once you access value, you’re now looking at the character. So if you wanted to find a Humanoid, for example, this is valid:

ObjectValue.Value:FindFirstChild("Humanoid")
2 Likes