Simple UI Click effect for buttons to light up?

Hello,

I have been struggling with my code recently. The way my GUI functions is in the case of hovering over a button, it will have a hover over effect via Mouse leave & Mouse enter.

The Issue I’m having is utilizing both Mouse leave & Mouse enter with having the function making the light up effect (highlight that you clicked it) without interference from both scripts…

Mouse Enter & Mouse Leave Script:

Capture2234

Function script:

script.Parent.MouseButton1Click:Connect(function()
Highlight.ImageTransparency = 0
end…

So whenever you click the image it highlights, but when you leave the image the hover script interferes with it and removes the highlight.

Solutions I’ve tried:

-Debounce

I’m simply looking for the best way to approach this without a headache…
I’ve gotten it to work but it creates a lot of debounce issues with the hover script and timing, etc…

Why would you need the second function? When the mouseenters the button, the imagetransparency is already 0. Just a quick question

I see what you’re asking, the second function is when you click it (the highlight effect permanently stays until affected by another button)

The enter/leave is for the purpose of knowing that you’re hovering over a button… Since I primary use image buttons, i create my own things for them.

I believe I got the solution I’ll edit this once I get it done…

edit: Issue solved

2 Likes