Error: Standalone lambdas cannot be accessed.(idk why its happening.)

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

im using godot4. Im trying to make a vehicle move using the sphere method. following a tutorial i added inputs using the “_process(delta)” function, and the code inside this function doesnt use “delta”. and this error pops up. The tutorial im following was made in 3.5(i couldnt find another sphere method vehicle tutorial). shoul;d i use another func?(new to this btw)

Can you share the error text and the relevant code snippet?

TRAILtheGREAT | 2023-04-26 17:28

:bust_in_silhouette: Reply From: Cyber-Kun

can you please provide a snippet of the code. it’s really hard to know what’s going on if we don’t know what the code is. lambdas are standalone functions inside of other functions.

func _ready():
    var lambda = func(): print("this is a lambda")
or you could use it like this:
func _ready():
    $MenuButton.pressed.connect(func(id_pressed): print(id_pressed))

I didn’t test the above code in godot but I have used lambdas in connect() before. this code might not directly work but with a few tweaks it should. the only thing I can think might need to change is the pressed signal for the MenuButton think it should be id_pressed