TextButton
A button with text that players click or tap.
- Inherits: TextLabel → GuiObject → Instance
- Creatable: Yes:
new TextButton(), orInstance.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.
Properties
Section titled “Properties”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
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”activated
Section titled “activated”Arguments: none
Client: fires when clicked or tapped.
Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged
Examples
Section titled “Examples”A restart button
Section titled “A restart button”import { PlayerGui, RemoteEvent, ReplicatedStorage, ScreenGui, TextButton, task, waitForChild, waitForLocalPlayer,} from '@rally/sdk';
// LocalScripttask.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());});