.connect() function in a for loop throws an error

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

Hello!
I was trying to make an endless runner type of game, but ran into difficulties using for loop to connect signals to the script. I tried manually connecting too, but it still throws the same error. Any help is appreciated.

Code:
Level code(Yes my endless runner game has levels):

extends Node2D

export (int)var speed = 200
var start = false

func spikes_action():
	print('dead')

func _ready():
	randomize()
	for spikes in $Map/Spikes.get_children():
		spikes.connect('spikes_action', self, 'dead')
	$Map/Goal.connect('goal_action', self, 'level_completed')

func _physics_process(delta):
	if Input.is_action_pressed("toggle_gravity"):
		start = true
	if start == true:
		for things in $Map.get_children():
			things.position.x -= speed*delta


func goal_action():
	print('Done!')

Spikes Code:

extends Area2D

signal dead



func _on_Area2D_body_entered(body:Node):
	if body.is_in_group('Player'):
		body.queue_free()
		emit_signal('dead')

Goal Code:

extends Node2D

signal level_completed


func _on_Area2D_body_entered(body:Node):
	if body.is_in_group('Player'):
		emit_signal("level_completed")
:bust_in_silhouette: Reply From: zenbobilly

You’ve mixed up the signal name (“dead”) with the function name to call (“spikes_action”) in the connect () call.