Text showing button

So I have game where I have board and under my desk I have buttons and I want to make them show things. When I press 1 button it will show text next click it will hide it. And same with others. Is this even possible?

Something like this should work if you have gui buttons that should show or hide text on text labels.


local texts = {
    -- text here,
    -- another text here,
    -- and so on
}

local buttons = {
    -- store the buttons here
}

local labels = {
    -- store the textlabels here
}

local isTextVisible = {}

for i, v in ipairs(buttons) do
    isTextVisible[i] = false
    button.Activated:Connect(function()
        local newIsVisible = not isTextVisible[i]
        isTextVisible[i] = newIsTextVisible
        labels[i].Text = newIsTextVisible and texts[i] or ""
    end)
end
2 Likes