Skip to content

NumberValue

Holds a number that scripts and players can read and watch.

  • Inherits: Instance
  • Creatable: Yes: new NumberValue(), or Instance.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.

Type: number · Default: 0 · Access: read/write · Replicates: yes

The number it holds.

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 { 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.');
});
});