Pet does not connect to character

I am made a pet shop where players can buy pets and then equip them in their inventory. When the player equips a pet, it changes a string value in their character to the equipped pet name. When it is changed, it does a function:


	local equippedPet ="StringValue")
	equippedPet.Name = "EquippedPet"
	equippedPet.Parent = plr
		if equippedPet.Value ~= nil then
			if game.ReplicatedStorage:WaitForChild("Pets"):FindFirstChild(equippedPet.Value) then

Since the value is changed, it calls for a function that puts the pet to the players avatar using this function.

local function equipPet(player,pet)

	local character = player.Character

	if pet ~= nil and character ~= nil then

		if character:FindFirstChild(player.Name.."'s Pet") then character[player.Name.."'s Pet"]:Destroy() end
		if character.HumanoidRootPart:FindFirstChild("attachmentCharacter") then 

		pet.Name = player.Name.."'s Pet"


		local modelSize = pet.PrimaryPart.Size

		local attatchmentCharacter ="Attachment")
		attatchmentCharacter.Visible = false
		attatchmentCharacter.Name = "attachmentCharacter"
		attatchmentCharacter.Parent = character.HumanoidRootPart
		attatchmentCharacter.Position =,1,0) + modelSize

		local attachmentPet ="Attachment")
		attachmentPet.Visible = false
		attachmentPet.Parent = pet.PrimaryPart

		local alignPosition ="AlignPosition")
		alignPosition.MaxForce = 25000
		alignPosition.Attachment0 = attachmentPet
		alignPosition.Attachment1 = attatchmentCharacter
		alignPosition.Responsiveness = 30
		alignPosition.Parent = pet

		local alignOrientation ="AlignOrientation")
		alignOrientation.MaxTorque = 25000
		alignOrientation.Attachment0 = attachmentPet
		alignOrientation.Attachment1 = attatchmentCharacter
		alignOrientation.Responsiveness = 30
		alignOrientation.Parent = pet
		pet.Parent = character

The problem is, when it is equipped, the pet appears and just falls to the ground. I am guessing it has to do with the equipPet function and the attachments. What can I change?

1 Like

If you Anchor the pet, does anything happen?

I have tried unachoring and anchoring the pet but it does not seem to produce any effect.

EDIT: I anchored all the parts in the model and now it just sits in one spot and does not follow the character at all. Instead, it sits in that one spot and moved up and down.