I have the same code for 2 projectiles but one works and other doesn't

Godot Version

4.0.6

Question

I have the same code for both projectiles but only one works.
When in game i type the spell name and send it in but only one appears while the other doesn't even appear.
Code:
bullet: fireball the one that works
icebolt: copy but doesnt work
gun: signal receiver for the spells
SpellBox: where i type spells in and send signal out if it matches.

I don’t see where the signals (fireball, icebolt) are connected. Show that code. The most probable reason for the problem is that you just don’t connect the icebolt signal to _on_spell_box_icebox function.

its the function on_spell_box_spellname

No such function in the screenshots. At least my eyes can’t find it.

3rd screenshot from the top after the func physics process

Nope. The 3rd screenshot is the gun.gd. It does have _physics_process, _on_spell_box_fireball and _on_spell_box_icebolt functions but no connects.

the function is the connection i just renamed it

If a signal is connected to a function (via the editor), it shows the green icon in front of it, like for _on_body_entered() in the first screenshot. Neither _on_spell_box_fireball() nor _on_spell_box_icebolt() show this icon, meaning they are not connected.

If you change the name of a function, you have to reconnect the signal, because with a new name it is considered a new function.

they are connected but the green icon doesn’t appear because i wasn’t on the selected node if i select the bullet node the green icon appears and vise versa for icebolt

Signals do not automatically connect to functions. Somewhere (probably in game.gd) you need to do something like this:

line_edit.fireball.connect(gun._on_spellbox_fireball)
line_edit.icebolt.connect(gun._on_spellbox_icebolt)

so i followed a tutorial for this initially:

Tutorial

and in it the connection is already made:
note its already connected since the fireball works

The tutorial doesn’t seem to use custom signals for this? It connects a Timer’s timeout signal to a function, and from there calls a shoot() function.

Also, just because your fireball signal is connected doesn’t mean your icebolt signal is as well. Are you getting the “signal received” and “end” prints?

yes it does print

And if you add some print in the icebolt script? Does that get printed?

added two print the reached end gets printed but hit doesn’t

Copy the content of _on_spellbox_fireball to the _on_spellbox_icebolt and test. If “icebolt” now works shooting fireballs, then the problem is probably in the icebolt scene.

Okay, so it does get instantiated, it just doesn’t show on screen. What is your icebolt.tscn? Are its sprite/texture set up and positioned correctly?

did that initially didn’t fix the problem

here is the sprite its an animated sprite with auto play and loop on

Is the root node of your fireball scene set to top_level? If yes, did you do the same for the icebolt scene?