Painting System not switching Colors

Hello,
I am making a test paint system, but I seem to have run into a problem. Everytime I try to switch the color, it’s still painting with the old color and not switching. I tried printing the brick color it received and it was accurate, showing the color I actually picked, but when I go to paint, it’s still the old color.
Server

local planes = workspace:WaitForChild("Planes")
local teller_event = game:GetService("ReplicatedStorage"):WaitForChild("ColorTeller")

teller_event.OnServerEvent:Connect(function(plr, brick_color: BrickColor)
	print(brick_color.Name)
	for _, plane: Model in pairs(planes:GetChildren()) do
		for _, part: Part in pairs(plane:GetChildren()) do
			if part:FindFirstChildOfClass("ClickDetector") then
				local cd: ClickDetector = part:FindFirstChildOfClass("ClickDetector")
				cd.MouseClick:Connect(function()
					part.BrickColor = brick_color
				end)
			end
		end
	end
end)

Client

local gui = script.Parent
local frame = gui:WaitForChild("MainFrame")
local teller_event = game:GetService("ReplicatedStorage"):WaitForChild("ColorTeller")
for _, button: TextButton in pairs(frame:GetChildren()) do
	button.MouseButton1Click:Connect(function() 
		print(button.Name, button:GetAttribute("Color").Name)
		teller_event:FireServer(button:GetAttribute("Color"))
	end)
end

Ok, so I found the issue, the server event was firing twice, one had the old color, and the other had the new color. I just added a debounce, and that fixed the problem.

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