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

How to make it change color when you keep clicking?

I want the color to change to BrickColor.new(1025) when you continue clicking it and if you click it again then it returns to BrickColor.new(1028). In other words, I want it to repeat the same color pattern. This is what I have so far:

game.Workspace.Tutu1.MyClickDetectorEvent.OnServerEvent:Connect(function()
	script.Parent.Parent.Chest.Handle.BrickColor = BrickColor.new(1028)
end)

1 answer

✓ Accepted answer

You can create an extra value to check which value you'd want the brick color to go to, or you can read out the brick color, and change it acordingly.

I'd suggest to use the first method like so:

local ColorPick = false
game.Workspace.Tutu1.MyClickDetectorEvent.OnServerEvent:Connect(function()
	if ColorPick then
		script.Parent.Parent.Chest.Handle.BrickColor = BrickColor.new(1025)
	else
		script.Parent.Parent.Chest.Handle.BrickColor = BrickColor.new(1028)
	end
	ColorPick = not ColorPick
end)

Basicly, I create the value ColorPick to deside which color the script has to choose. After the color changes, the script will set the colorPick value to either false or true, depending on what it was before.

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