NumberValue
Holds a number that scripts and players can read and watch.
- Inherits: Instance
- Creatable: Yes:
new NumberValue(), orInstance.new('NumberValue', parent). - Replication: Replicated: clients get a copy, and changes the server makes reach them.
Value objects hold one piece of state in the tree, where every script on the same side can find
it and players can see it if it’s somewhere that replicates (for example in ReplicatedStorage, or
inside a player). Watch it with getPropertyChangedSignal('value').
NumberValues, StringValues and BoolValues inside a player’s leaderstats folder show on the
in-game leaderboard, one column per name. Players are sorted by the first column when it’s a
NumberValue, highest first.
Properties
Section titled “Properties”Type: number · Default: 0 · Access: read/write · Replicates: yes
The number it holds.
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”A score on the leaderboard
Section titled “A score on the leaderboard”import { Folder, NumberValue, Players } from '@rally/sdk';
Players.playerAdded.connect((player) => { const stats = new Folder(); stats.name = 'leaderstats'; const score = new NumberValue(); score.name = 'Score'; score.parent = stats; stats.parent = player;
score.getPropertyChangedSignal('value').connect(() => { if (score.value >= 100) player.kick('You win! Thanks for playing.'); });});