Client-Side Button Color Change Issue – Print Confirms Change, But No Visible Effect

I’m developing a client-side system, but I’m facing an issue: when I activate the button, its color should change. The console confirms the change, but visually, nothing happens. I’ve checked, and no other button is interfering. Any help would be greatly appreciated!

Script:
local Folder = workspace.ButtonsFolder:WaitForChild("MustardWorld")

local Prompt

local Button

local X = 0

local CollectionService = game:GetService("CollectionService")

for _, buttonModel in pairs(CollectionService:GetTagged("MustardButtons")) do
	Button = buttonModel:WaitForChild("Button")

	Prompt = Button:WaitForChild("ProximityPrompt")

	Prompt.Triggered:Connect(function()

		print(Prompt.Parent.BrickColor)
		if Button.Color == Color3.fromRGB(168, 0, 0) then

			local Sound = Button:WaitForChild("Sound")
			Sound:Play()

			local Particle = Button:WaitForChild("ParticleEmitter")
			Particle.Enabled = true

			task.spawn(function()
				wait(1)
				Particle.Enabled = false
			end)

			Button.Color = Color3.fromRGB(36, 168, 21)
			Prompt.Enabled = false

			X = X + 1

			print(X)

		end
	end)
end

Video:

Place local before the Button and Prompt variables inside the for-loop (and not outside) to make sure those variables gets its own separate reference for each iteration.

local Prompt
local Button

for _, buttonModel in pairs(CollectionService:GetTagged("MustardButtons")) do
local Button = buttonModel:WaitForChild("Button")
local Prompt = Button:WaitForChild("ProximityPrompt")
1 Like

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