TextButton|TextButtons
and ImageButton|ImageButtons
.TextButton
is very similar to a TextLabel
, except that a player can activate it with a click. Internally, it also shares many of the same visual properties as a text label — font, background color, stroke color, etc.ImageButton
is like an interactive version of the ImageLabel
object and it uses a custom image that you upload to Roblox. It also shares most of the same properties as its non-button counterpart.ImageButton
to the screen and flip it between a normal appearance and a more colorful appearance when a player activates it.LocalScript
. This is similar to the Script
object which you may be familiar with, but a LocalScript
is used to perform actions that only relate to a specific player and things happening on that player’s screen, such as detecting their input on the screen or displaying GUI elements (in contrast, a regular Script
is used for things that occur in the overall game world and which affect all parts and players in the game).ImageButtonNormal.png
file, make sure you uploaded ImageButtonActivated.png
.'rbxgameasset://Images/ImageButtonActivated'
'rbxgameasset://Images/ImageButtonNormal'
button
which tells the script what specific object it’s linked to. In this case it’s linked to the image button, the “parent” of the script.toggled
which lets us track the current state (appearance) of the button. Because the button begins in the normal state, we set the variable’s value to false
.toggled
is false
(the button is off), the Image
property of the button will be changed to the brighter activated image and the toggled
variable will be set to true
(meaning the button is on).else
) will be triggered if the button is in the activated state. This condition resets the button to the normal appearance and sets toggled
back to false
.GuiButton/Activated|Activated
event. This will make the function run whenever the button is activated.GuiButton/Activated|Activated
event is the most reliable for basic buttons, providing standard button behavior on all platforms from PC to phone/tablet to console.TextButton
or ImageButton
object, and hooking up a local script lets you detect basic button activation as well as swap between two images.