How do I play a sound on_mouse_entered without it spamming?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thayus

Hiyo!
I’m using a TextureButton, and want a click noise to play whenever I hover my mouse over the top of it. How would I do it without it spamming the sound? (I turned off looping by the way)

Thanks,
Thayus.

Dİd you use Signal ?
and show the code. just that part

ramazan | 2022-02-05 08:27

:bust_in_silhouette: Reply From: rossunger

easiest way is to have a bool variable that you set to true on mouse enter, and false on mouse exit…

var playedSound = false

func myMouseEnter(event):
  if not playedSound:
     mySound.play()
     playedSound = true

func myMouseExit(event):
   playedSound = false