Hey there!
So what I am trying to achieve is, you click a button, the border goes red, youc click that same button again, the border goes green.
If tried looking for tutorials, something about debounce = true, but when I tried it, all it did was go red but then when I clicked it again, nothing happened.
Code
local function mClick()
local debounce = false
if debounce == false then
SoundS.Sound.Playing = false
Music.BorderColor3 = Color3.fromRGB(239, 155, 156)
elseif debounce == true then
SoundS.Sound.Playing = true
Music.BorderColor3 = Color3.fromRGB(184, 239, 160)
end
end
Music.MouseButton1Click:Connect(mClick)
You need to define the debounce above the function scope.
local debounce = false
local function mClick()
debounce = not debounce
if not debounce then
SoundS.Sound.Playing = false
Music.BorderColor3 = Color3.fromRGB(239, 155, 156)
elseif debounce then
SoundS.Sound.Playing = true
Music.BorderColor3 = Color3.fromRGB(184, 239, 160)
end
end
Music.MouseButton1Click:Connect(mClick)