Restore original TextColor3 value on multiple buttons when clicking a button

So basically, what the title says. I have 5 buttons that when clicked, I want them to change their TextColor3 property but when I click on another button, the button I clicked before restores itself to it’s original greyed out state.

This is the current behavior of those buttons.

I’m getting those TextButtons in a numeric loop because adding one by one is a no-go:

-- // vars //
local PresetNames = script.Parent.Background.Presets:GetChildren()

-- // functions//
for i = 1, #PresetNames do
	local Preset = PresetNames[i]
	if Preset:isA("TextButton") then
		Preset.MouseButton1Click:Connect(function()
			-- code here
		end)
	end
end

2020-09-08 20_02_57-FireflyInit - Roblox Studio

However, I’ve tried adding a BoolValue to each button with absolutely no idea how to make this work.

Any kind of help would be appreciated.

1 Like

You can change all the text colors to the original upon each individual button click and change the one that was clicked to the desired text color

1 Like

try this:

for i,v in pairs(script.Parent.Background.Presets:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Down:Connect(function()
--do whatever
for _,b in pairs(script.Parent.Background.Presets:GetChildren())
if b.Name ~= v.Name then
--do whatever
end
end
end)
end
end
1 Like

Thank you!

I think I’ve tried this but I didn’t do it well the few times I tried, lol.

1 Like