Define all part that have same name

Hi!
I ran into a little problem.
I have made a tree and name all of its leaves a specific name.
I want to make all leaves shake:
script (totally free model)

pos = script.Parent.Position
pos = Vector3.new(pos.x, pos.y-0.2, pos.z)
x = 0
z = 0
T = -99999
tall = script.Parent.Size.Y / 2
math.randomseed(tick())
rand = (math.random(0,20))/1
while true do
x = pos.x + (math.sin(T + (pos.x/3)) * math.sin(T/70))/15
z = pos.z + (math.sin(T + (pos.z/4)) * math.sin(T/10))/12
script.Parent.CFrame =
	CFrame.new(x, pos.y, z) * CFrame.Angles((z-pos.z)/tall, 0,(x-pos.x)/-tall)
	wait()
	T = T + 0.12
end

I don’t want to copy and paste this into every leave block on the map because it time-wasting.
how could I define all parts that share the same name?
(pls I’m a noob at programming)

local leavesFolder = workspace:WaitForChild("Leaves") --change path to wherever leaves are stored

for _, part in ipairs(leavesFolder:GetDescendants()) do
	if part:IsA("BasePart") and part.Name == "Leaf" then --check if name matches name of parts you want to match
		--do stuff
	end
end
2 Likes