Skip to content

ObjectValue

Holds a reference to another instance.

  • Inherits: Instance
  • Creatable: Yes: new ObjectValue(), or Instance.new('ObjectValue', parent).
  • Replication: Replicated: clients get a copy, and changes the server makes reach them.

See NumberValue for how value objects are used. A reference replicates as a link to the same object on each player’s device.

Type: Instance | null · Default: null · Access: read/write · Replicates: yes

The instance it points to, or null. On a player’s device it stays null until the target has arrived there, so it’s null for targets players never receive (in ServerStorage, for example).

Inherited from Instance: name, archivable, id, className, parent, destroyed

Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString

Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged

import { ObjectValue, Players, ReplicatedStorage, print } from '@rally/sdk';
const it = new ObjectValue();
it.name = 'It';
it.parent = ReplicatedStorage;
Players.playerAdded.connect((player) => {
if (!it.value) it.value = player;
});
it.getPropertyChangedSignal('value').connect(() => print('now it:', it.value));