#Area2D on click signal

8 messages · Page 1 of 1 (latest)

tight saddle
#

Hello, I'm trying to use the following code to change the visibility of an "incorrect" text when an area is clicked. I was following a tutorial and tried to implement it similarly but I'm recieving some errors , why is that?

extends Area2D

@onready var incor = get_node("incorrect1")

func _ready() -> void:
input_pickable = true
self.connect(func(event):
if event.is_action_pressed("mouseleft"):
incor.visibile = true)

Errors:

Line7:Too few arguments for "connect()" call. Expected at least 2 but received 1.
Line 7:Invalid argument for "connect()" function: argument 1 should be "StringName" but is "Callable".

vagrant vesselBOT
#
Embedding code in discord messages
Inline Code

When you surround some words with single backticks like `this`, it will be formatted as code.

Code Blocks

You can also include code blocks by surrounding the code with three backticks. If you add "swift" then you will also get basic syntax highlighting:
```swift
print("hello world")
```
Discord will then show it as a code block like this:

print("hello world")
Upload

If your code snippet is rather long, you can upload it to a text paste site. One option that supports syntax highlighting for GDScript is https://bpa.st/

silk coyote
tight saddle
#

Oh that cleared some things up, but now I'm getting a new error sorry
Line 7:Identifier "event" not declared in the current scope.
what does this mean?

#

I thought that I'm already declaring it inside so how do I do it outside the connect function without repeating?

silk coyote
#

Can you post your new code

tight saddle
#

Sure, sorry for taking long

extends Area2D

@onready var incor = get_node("incorrect1")

func _ready() -> void:
    input_pickable = true
    event.is_action_pressed("mouseLeft").connect(func(event):
        if event.is_action_pressed("mouseleft"):
            incor.visibile = true)

silk coyote