How would I make a button change selection?

I have 8 image buttons that are all grouped under a folder.

I want to make it so that if I press one button, that button has a different colored outline, but if I press a different button the 1st buttons outline changes to what it was before while the other button gets the different color outline.

for i, button in folder do
	button.Activated:Connect(function()
		local unselected
		
		if unselected and unselected ~= button then
			unselected.UIStroke.Color = Color3.fromRGB(130, 118, 26)
		end
		
		unselected = button
		button.UIStroke.Color = Color3.fromRGB(94, 211, 31)
	end)

end

This is the current script I’m using and it only applies the second color to the outlines of the buttons and doesn’t remove it when I press a different button.

move local unselected to the top of the script.

basically whats happening is that each time a button activates, a new local unselected is created that cant be accessed when another button is activated

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.