TextButton

A button with a text label on it.

A TextButton is a TextLabel the player can click. It has the same text settings and the same Frame members, and it adds no properties of its own.

Members

TextButton has every member of TextLabel, which includes every member of Frame, plus the shared Instance members in Instance.

There is no Activated event. Use MouseButton1Click for a left click and MouseButton2Click for a right click.

Events

Every GuiObject carries these; none of them passes arguments. A click fires Down, then Up, then Click.

Event When it fires
MouseEnter The pointer moved over the button.
MouseLeave The pointer moved off it.
MouseButton1Click A full left press and release on it.
MouseButton1Down A left press began.
MouseButton1Up A left press ended.
MouseButton2Click A full right press and release on it.
MouseButton2Down A right press began.
MouseButton2Up A right press ended.

Example

local playerGui = game:GetService("Players").LocalPlayer.PlayerGui

local screen = Instance.new("ScreenGui")
screen.Name = "Menu"
screen.Parent = playerGui

local button = Instance.new("TextButton", screen)
button.Size = UDim2.new(0, 180, 0, 44)
button.Position = UDim2.new(0.5, -90, 0.5, -22)
button.BackgroundColor3 = Color3.fromRGB(45, 110, 200)
button.BackgroundTransparency = 0
button.Text = "Play"
button.TextColor3 = Color3.new(1, 1, 1)
button.TextSize = 18

local clicks = 0
button.MouseButton1Click:Connect(function ()
    clicks = clicks + 1
    button.Text = "Clicked " .. clicks
end)

See also