Quick answer: Godot 4 instantiated scene becoming orphaned because the parent was freed the same frame? add_child queues but free is immediate - use call_deferred or check is_instance_valid before adding.
Bullet hits enemy. Death VFX scene instantiated as child of enemy; enemy queue_free()'d on the same frame. VFX is now floating orphan.
Use call_deferred
call_deferred("add_child", vfx)Deferred adds run at end-of-frame. By then, the parent is either still valid or already in the tree's free queue.
Add to a stable parent
For death VFX, parent to a persistent VFX manager node instead of the dying enemy. The VFX outlives its emitter naturally.
Check is_instance_valid before add
if is_instance_valid(target):
target.add_child(vfx)Defensive but explicit. Useful when the timing is unclear.
“queue_free() is queued; add_child() is not. Mismatched lifetimes cause orphans.”
Build a small VFX manager autoload. Every death VFX, hit spark, and pickup particle goes through it - lifetime management lives in one place.