How to Loop Through to get Specific Character Parts?

Hi! I was wondering if there was a way to use a for loop to loop through a character’s parts to only reference or get specific character body parts. For example I want to loop through a character’s baseparts and only find the UpperTorso and the Head (R15 Body Type).

I tried writing the code like this, but it doesn’t work:

		for _, v in pairs(Character:GetChildren()) do
			if v == "UpperTorso" or "Head" then
				print(v)
			end
		end

It doesn’t print only the UpperTorso or the Head, but instead prints all of the the character’s descendants including local scripts. Can someone help me find a solution to this? Thanks!

I think you should use :FindFirstChild like:

local upperTorso = Character:FindFirstChild("UpperTorso")
if upperTorso then
    do something
end

Try this code. The reason this one works is because when you check using the if statement, you have to do v == "UpperTorso" and v == "Head".

for _, v in pairs(Character:GetChildren()) do
	if v.Name == "UpperTorso" or v.Name == "Head" then
		print(v)
	end
end