ObjectValue

Point at another object in the tree, so code can follow the link.

Value is another instance, or nil by default. The project file keeps the target by its id, so a rename never breaks the link, and a target outside the project is saved as nil. Clone of a tree that holds both the ObjectValue and its target points the copy at the copied target; a target outside the copy is kept.

Made with Instance.new("ObjectValue") or Clone().

Example

Point at an instanceShotScript
-- An ObjectValue points at another instance, or at nothing (nil) when new.
local shop = Instance.new("Folder")
shop.Name = "Shop"
local apple = Instance.new("StringValue", shop)
apple.Name = "Apple"
local pick = Instance.new("ObjectValue", shop)
pick.Name = "Pick"
print("a new ObjectValue points at " .. tostring(pick.Value))
pick.Value = apple
print("Pick points at " .. tostring(pick.Value))

-- a copy that points inside the copied tree points at the copy
local copy = shop:Clone()
local copiedPick = copy:FindFirstChild("Pick") :: ObjectValue
print("the copy's Pick points at the copy's Apple: " .. tostring(copiedPick.Value == copy:FindFirstChild("Apple")))
What it printedOutput
a new ObjectValue points at nil
Pick points at Apple
the copy's Pick points at the copy's Apple: true

Properties

NameTypeDefaultDescription
ValueShotInstance?The instance it points at, or nil; a Clone copying both points at the copy, and the project file keeps the target by its id.
From ShotInstance 33