Part doesnt change color to indicate cooldown

This part should play a sound when clicked and then have a 10 second cooldown untill its possible to use it again, the part should be red when its in cooldown and green when ready to use. its always red, help?


local sound = script.Parent.Sound
local cd = false
local button = workspace.Button
local sound = script.Parent.Sound
local Green = Color3.fromRGB(0, 255, 0)
local Red = Color3.fromRGB(255, 0, 0)

function playsound()
	if cd == false then
		cd = true
		sound:play(sound)
		button.Color = Red
		wait(10)
		cd = false
		button.color = Green
	
	end
end

script.Parent.ClickDetector.MouseClick:connect(playsound)


Think it’s because in the 2nd button.Color you wrote Color as color, you need to capitalize the c

1 Like

changed it and still the same issue


local sound = script.Parent.Sound
local cd = false
local button = workspace.Button
local sound = script.Parent.Sound
local Green = Color3.fromRGB(0, 255, 0)
local Red = Color3.fromRGB(255, 0, 0)

function playsound()
	if cd == false then
		cd = true
		sound:play(sound)
		button.Color = Red
		wait(10)
		cd = false
		button.Color = Green
	
	end
end

script.Parent.ClickDetector.MouseClick:connect(playsound)


Is it staying red the only thing or is there more to it?

its only staying red, the sound plays like its supposed to

1 Like

i just tried the script myself and it worked perfectly, im not sure what the issue is

so its red while the cooldown is active?

1 Like

so apparently the script needs to be closed for the changes to be applied, i think this is new because i had never done that

1 Like


yeah