You generally want to add items, like loot or stuff that spawns, onto the game layer. This would be the node in your game where the level is (that same layer that the player is walking inside). One way to do this is to have a main script on the level or on the top node, which has a function spawn_item()
or whatever that creates the item. It can take parameters so it can spawn different items. Then when the enemy dies, it calls that function, or emits a signal. For example.
# when the enemy dies
get_node("/root/Game/Level").spawn_item("Sword", global_position)
This would assume the top node in your game is called "Game" and has a child called "Level" and the "Level" has the script with the spawn_item()
function. Then in that script, you could do something like:
func spawn_item(item_type, item_position):
if item_type == "Sword":
var sword = SwordAsset.instance()
sword.global_position = item_position
add_child(sword)