Differentiating between a Model and a Part with the same name

Hello, looking for some quick (and hopefully easy) help.

There is a model (part of the morph) that is called “LeftUpperArm”, and a humanoid part also called “LeftUpperArm”, both located within a player’s character.

I am trying to access an instance within the character’s morph called CountryFlag, that is inside the “LeftUpperArm” Model.

When I try to access it like this -
player.Character:WaitForChild(“LeftUpperArm”).CountryFlag
-the script thinks I am trying to access the “LeftUpperArm” Humanoid Part instead of the model, thus returning with an error since there is no CountryFlag within the Humanoid Part.

How do I get the script to call the Model instead of the Part, if they have the same name? Everything that I have tried always ends up picking up the Part. This is the first time I’ve run into this sort of issue.

Thanks.

You could iterate through each child and check if it is both a model and with the name “LeftUpperArm”.

for _, v in pairs(player.Character:GetChildren()) do
	if v:IsA("Model") and v.Name == "LeftUpperArm" then
		-- access it within v here
		break
	end
end
3 Likes

Solved my problem! Thanks very much.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.