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)
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)