Equip Model

local pet = script.Parent.Parent

local modelSize = pet.PrimaryPart.Size

local equipped = false


local function equipPet(otherPart)

local player = game.Players:FindFirstChild(otherPart.Parent.Name)

if player and not equipped then

equipped = true

local attachmentCharacter = Instance.new('Attachment')

attachmentCharacter.Visible = false

attachmentCharacter.Parent = player.Character.HumanoidRootPart

attachmentCharacter.Position = Vector3.new(1,1,0) + modelSize

local attachmentPet = Instance.new('Attachment')

attachmentPet.Visible = false

attachmentPet.Parent = pet.PrimaryPart

local alignPosition = Instance.new('AlignPosition')

alignPosition.MaxForce = 25000

alignPosition.Attachment0 = attachmentPet

alignPosition.Attachment1 = attachmentCharacter

alignPosition.Responsiveness = 25

alignPosition.Parent = pet

local alignOrientation = Instance.new('AlignOrientation')

alignOrientation.MaxTorque = 25000

alignOrientation.Attachment0 = attachmentPet

alignOrientation.Attachment1 = attachmentCharacter

alignOrientation.Responsiveness = 25

alignOrientation.Parent = pet

pet.Parent = player.Character

end

end


pet.PrimaryPart.Touched:Connect(equipPet)