Trying to figure out how to use a list to mess with clones

Godot Version

4.5

Question

How do i save thing to a list in such a way that i can use a for loop to modify them all, weather that be changing their position to a randomized new position at a button press, or doubling them( i imagine for tree in treelocs is the best way to do that???). pretty much, what i imagine my code is doing right now is just checking the value of their position and saving that to a list, but what id like to be able to do is save them in a way that lets me change things about them. ALSO, if yall got any tips for getting better at scripting id appreciate

extends Node
#i wanna save their position to the list then randomize their position
# or maybe do something like double them.
# but my problem is, i think it saves the value of .position to the list, not                 any way to actually modify the tree
var Treelocs = []
var Treecount = 0
var Hp = 100
func Newsprite(sprite_2d: Sprite2D) -> Sprite2D:
			var new_sprite2d: Sprite2D = sprite_2d.duplicate()
			new_sprite2d.scale = Vector2(randf(), randf())
			new_sprite2d.position = Vector2(randf_range(0,1150), randf_range(0,650))
			Treelocs.append(new_sprite2d.position) 
			add_child(new_sprite2d) 
			return new_sprite2d
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	$Label.text = " NOOB NOOB NOOB NOOB NOOB NOOB NOOB "
	$Label.modulate = Color.GREEN
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass

func _input(event):
	if event.is_action_pressed("MyAction"):
		Treecount = Treecount + 1
		Newsprite($Node2tree/Sprite2D)
	elif event.is_action_pressed("Gamerbutton"):
		print("There are :", Treecount,"Trees")
		print("The trees are at", Treelocs) 
	elif inpit.is_action_pressed("bac"):
		for loc in Treelocs # this is where i get confused
	else :
		pass

Vector2 is a copied type, when you append it to the list you are appending a copy. If you append the Node2D then you can edit it’s position property since Node2D is a referenced type. You can tell a type is referenced if it has a .duplicate function, otherwise it will be copied on assignment.

So i just append the “new_sprite2d” instead of the “new_sprite2d.position”?

Yes and then in your for loop you can assign loc.position = ...