Changing the "ButtonStyle" with script

Hi,
I am trying to program a TextButton so that when it is clicked it changes its style.

I tried to get some information from the DevHub and found this: ButtonStyle | Documentation - Roblox Creator Hub

However, I can’t manage to change the style.
I already tried script.Parent.Option3Text.Style = “5” or script.Parent.Option3Text.Style = 5.

Do you know how I could change it?

2 Likes

I finally figured it out:

script.Parent.Option3Text.Style = “5” is WRONG for If statements.
Instead you have to use
Parent.Option1Text.Style = Enum.ButtonStyle.RobloxRoundDropdownButton.

2 Likes

I know this is an old post but when you’re assigning to a property which expects a particular enumeration type value you have multiple options. You can assign an enumeration item of the expected enumeration type itself, you can assign a code (number value) which represents that enumeration or you can assign the enumeration item’s name (string value).

local textbutton = script.Parent
textbutton.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
local textbutton = script.Parent
textbutton.Style = 5
local textbutton = script.Parent
textbutton.Style = "RobloxRoundDropdownButton"