How to use one tool to change a TextLabel color twice

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to make this tool change color twice each time i click it (Example, I click, the TextLabel changes to black, I click again and it returns it to Orange.)

  2. What is the issue? It’s only turning black

  3. What solutions have you tried so far? I’ve tried reading other articles and forums


tool.Activated:Connect(function()
		local Player = game.Players:FindFirstChild(tool.Parent.Name)
		local Character = Player.Character
		if Character then
			local Head = Character:FindFirstChild("Head")
			if Head then
				local OverheadGui = Head:FindFirstChild("OverheadGui")
				if OverheadGui then
					local TextLabel = OverheadGui:FindFirstChild("TextLabel")
					if TextLabel then
					OverheadGui.TextLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
					end
				end
			end
		end
end)

Try this:

local currentClick = 1

tool.Activated:Connect(function()
		local Player = game.Players:FindFirstChild(tool.Parent.Name)
		local Character = Player.Character
		if Character then
			local Head = Character:FindFirstChild("Head")
			if Head then
				local OverheadGui = Head:FindFirstChild("OverheadGui")
				if OverheadGui then
					local TextLabel = OverheadGui:FindFirstChild("TextLabel")
					if TextLabel then
                        if currentClick == 1 then
					        OverheadGui.TextLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
                            currentClick += 1
                        else 
                            OverheadGui.TextLabel.TextColor3 = Color3.fromRGB(yourOrangeColor)
                            currentClick = 1
                        end
                        
					end
				end
			end
		end
end)

Thanks it worked! (Is there any way to loop it? so it changes to black then orange then black and orange, etc. (Sorry, I’m not the best scripter)

I just edited the script I posted, I forgot one line (the one that loops it)

I appreciate the quick response! Thank you.