ObjectValue
Holds a reference to another instance.
- Inherits: Instance
- Creatable: Yes:
new ObjectValue(), orInstance.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.
Properties
Section titled “Properties”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
Methods
Section titled “Methods”Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString
Events
Section titled “Events”Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged
Examples
Section titled “Examples”Remember who is “it”
Section titled “Remember who is “it””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));