Skip to content

TextButton

A button with text that players click or tap.

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

A TextButton is a TextLabel that fires activated on the player’s device when clicked or tapped. To make something happen in the shared game, have a LocalScript send a RemoteEvent to the server.

Inherited from TextLabel: text, textColor, textSize, fontWeight, textAlign, textWrapped

Inherited from GuiObject: position, positionScale, size, sizeScale, anchorPoint, backgroundColor, backgroundTransparency, cornerRadius, visible, zIndex

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

Arguments: none

Client: fires when clicked or tapped.

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

import {
PlayerGui,
RemoteEvent,
ReplicatedStorage,
ScreenGui,
TextButton,
task,
waitForChild,
waitForLocalPlayer,
} from '@rally/sdk';
// LocalScript
task.spawn(async () => {
const me = await waitForLocalPlayer();
const gui = await waitForChild(me, 'PlayerGui', PlayerGui);
const hud = await waitForChild(gui, 'HUD', ScreenGui);
const restart = await waitForChild(hud, 'Restart', TextButton);
const askRestart = await waitForChild(ReplicatedStorage, 'Restart', RemoteEvent);
restart.activated.connect(() => askRestart.fireServer());
});