When i Click Buttons Every Button Becomes Green But Only The Selected Button Should Be Green

Hello There,

I have this issue where i click every 5 button’s they all turn green but what i expected is that ONLY the Selected Button Value Is Green Everything else is Black but it is not working

Here is the code

local plr = game.Players.LocalPlayer
local CurrentButton = plr:WaitForChild("SelectedButton")

while wait() do
	if script.Parent:FindFirstChild(CurrentButton.Value) then
		local SelectedButton = script.Parent:FindFirstChild(CurrentButton.Value)
		
		local NotSelectedButton = script.Parent:GetChildren()
		
		SelectedButton.ImageColor3 = Color3.fromRGB(0,255,0)
		
		NotSelectedButton.ImageColor3 = Color3.fromRGB(0,0,0)
		
		SelectedButton.ImageColor3 = Color3.fromRGB(0,255,0)
	end
end

I could help if you were to give me a bit more detail.

Just insert a local script inside of the button, and write:

function changeColor()
script.Parent.ImageColor3 = Color3.fromRGB(0,255,0)
end

script.Parent.MouseButton1Click:Connect(changeColor)
2 Likes

i would have to check if their image color 3 is black or green but ill try it

1 Like

When i click 2 Buttons at a time they turn green which is unfortunate

i would have to click it again to turn it black again

Im having this issue where all my buttons turn green when i click them all but only 1 Button Should be Green not ALL Green

Already to use GetChildren you have to loop for :

for i,v in pairs(NotSelectedButton) do
	
end

yes i got an error but i fixed it thank you