Godot Version
Replace this line with your Godot version
Question
Why isn’t this working and can someone please explain it to me in a detailed manner im trying to learn coding through trial and error i just need to get some more experience.
func _on_area_2d_mouse_entered() -> void:
if _on_area_2d_mouse_entered():
$"Upgrades/+ 1 CashMulti/Price".visible = true
else:
$"Upgrades/+ 1 CashMulti/Price".visible = false
" I might be back because after that i’m going to try to make the text sort off follow the mouse till it leaves the area."
You need to use the excited signal as well, and your if statement isn’t valid
Sorry i’m not familiar with that term yet??
The signal mouse_entered emits once and only when the mouse overlaps with the given area, this function connected to that signal will only handle the visible = true portion because it does not trigger when the mouse exits. You will need to connect mouse_exited to another function to handle visible = false.
Remember that functions run from top to bottom once called, an “entered” signal will not be processing at the same time as an “exited” signal
Calling a function within itself can cause an infinite loop, and if statement expect a true/false bool value, but the function returns void so if it doesn’t crash your game from the infinite loop- it won’t work with the if statement anyways.