Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do I make this script make only the first button clicked turn green?

I have this script that is supposed to check that once a part is clicked, it checks if every button is red and if they are red, then it turns green. This script is the exact same in the other buttons so it should only work for the first person to press their button, however, this script turns every button pressed green

--buttons is a folder with 8 button parts

script.Parent.bb.MouseClick:Connect(function(hit)
	
	
	a=  game.Workspace.buttons:GetChildren()
	for i, child in ipairs(a) do
	if child.BrickColor.Name == "Really red"
	then 
		print("XD")
		script.Parent.BrickColor = BrickColor.new("Earth green")
		wait(10)
		script.Parent.BrickColor = BrickColor.new("Really red")
	end
	
	end
	
	
end)

please help

1 answer

Alright, you should try if child.BrickColor == BrickColor.new("Really red") and you should add a local before a local a = ....

2 comments

0

still doesnt work

0

change ipairs to in pairs

This discussion is preserved as it was. New answers, comments, and votes are closed.