How would i make pet with same name also show as equipped

i have made a few of these posts, just wanted to know how i would do this. i have tried looping but it equips all pets so i did it this way instead. this is my biggest problem.

function UpdateEquippedp()
	
	
	local hasran = false
	
	
	
	local Pet1 = plr.PetEquipped1.Value
	if Pet1 ~= "" then
		local button = script.Parent.PetInventoryFrame.Frame.innerFrame.PetButtonHolder:FindFirstChild(Pet1)
		button.Equipped.Value = true
		button.UIStroke.Color = Color3.fromRGB(80, 255, 61)
		button.TickIcon.Visible = true
		button.SelectionOrder = 1
	end
	
	
	
	
	
	
	local Pet2 = plr.PetEquipped2.Value
	if Pet2 ~= "" then
		local button1 = script.Parent.PetInventoryFrame.Frame.innerFrame.PetButtonHolder:FindFirstChild(Pet2)
	button1.Equipped.Value = true
	button1.UIStroke.Color = Color3.fromRGB(80, 255, 61)
	button1.TickIcon.Visible = true
		button1.SelectionOrder = 1
	end
	
	
	

	local Pet3 = plr.PetEquipped3.Value
	if Pet3 ~= "" then
		local button2 = script.Parent.PetInventoryFrame.Frame.innerFrame.PetButtonHolder:FindFirstChild(Pet3)
	button2.Equipped.Value = true
	button2.UIStroke.Color = Color3.fromRGB(80, 255, 61)
	button2.TickIcon.Visible = true
		button2.SelectionOrder = 1
	end
	
	
end

UpdateEquippedp()

the code above is the code that changed the appearance.

the video shows the issue.

3 Likes

Could you elaborate more on what’s going on? I’m kinda confused still.

so, i have 3 values inside the player, they all hold the currently equipped pet names. In the function it gets the value and then finds it inside of the pet template holder which is what holds all the pets and changes the look if it is equipped. the problem i am facing is when you have 2 of the same name pets( pets with the same name) equipped it only shows that 2 of them are equipped not 3 like its supposed to be.