This worked! I knew it would be something simple like this.
Here's what I did:
1) Added an onready boolean near the top of my Global script to control if the sound can play or not:
#Extensions
extends Node
#Variables
onready var buttonMoveSound = true
2) Changed my master button code's on focus entered() function (see the rest of this code above) to be on focus exited(), which saved the issue of the noise playing every time a button showed up for the first time, and then added an "if" statement inside to say if the global variable was true, play the noise, else, don't, so that I could turn it on and off in different situations on the fly within my game:
func _on_focus_exited():
if Global.buttonMoveSound == true:
var move = Sound.instance()
self.add_child(move)
move.stream = Move
move.play()
else:
pass
3) Added a line of code to my pause menu code (just a good example of something in my game with a bunch of buttons that enters and leaves the screen frequently) that says when the state is switched from being in the pause menu to being unpaused, set the global variable to false to shut the audio off (so that it doesn't play the move sound when the focus exits from the button that was just on screen in the pause menu), and then when the tween of the pause menu exiting the screen ends, set the global variable back to true to play the audio next time the game's paused:
enum {
UNPAUSED,
PAUSEBAR,
}
func _process(delta):
match state:
UNPAUSED:
unpaused_state(delta)
PAUSEBAR:
pausebar_state(delta)
func unpaused_state(delta):
get_tree().paused = false
tweenPauseBarIn.interpolate_property(pauseBar, "rect_position",
Vector2(-320,0), Vector2(0, 0),
Tween.TRANS_SINE)
tweenPauseBarIn.start()
state = PAUSEBAR
func pausebar_state(delta):
get_tree().paused = true
if Input.is_action_just_pressed("pause"):
tweenPauseBarOut.interpolate_property(pauseBar, "rect_position",
Vector2(0,0), Vector2(-320, 0),
Tween.TRANS_SINE)
tweenPauseBarOut.start()
Global.buttonMoveSound = false
state = UNPAUSED
func _on_TweenPauseBarOut_tween_completed(object, key):
Global.buttonMoveSound = true
4) I will now have to repeat step 3 whenever I create new scenes with buttons, but this is no big deal. Easy to fix each time.