Error: Model:SetPrimaryPartCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.
local RS = game:GetService("ReplicatedStorage")
local Events = RS.Events
local Pets = RS.Pets
local PetCreate = Events.PetCreate
local tab = {}
function CreatePet(player, Index)
local character = player.Character or player.CharacterAdded:Wait()
if character.PrimaryPart:FindFirstChild("Attachment") then
character.PrimaryPart:FindFirstChild("Attachment"):Destroy()
end
local Pet = Pets[Index]:Clone()
local AttachA = Instance.new("Attachment")
AttachA.Parent = Pet.PrimaryPart
local AttachB = Instance.new("Attachment")
AttachB.Position = Vector3.new(3,3,0)
AttachB.Parent = character.PrimaryPart
local AlignPosition = Instance.new("AlignPosition")
AlignPosition.Attachment0 = AttachA
AlignPosition.Attachment1 = AttachB
local AlignOrientation = Instance.new("AlignOrientation")
AlignOrientation.Attachment0 = AttachA
AlignOrientation.Attachment1 = AttachB
AlignPosition.MaxForce = 30000
AlignOrientation.MaxTorque = 30000
AlignPosition.Parent = Pet.PrimaryPart
AlignOrientation.Parent = Pet.PrimaryPart
Pet:SetPrimaryPartCFrame(character.PrimaryPart.CFrame)
Pet.Parent = workspace
tab[player] = Pet
end
PetCreate.OnServerEvent:Connect(function(player,Index)
if not tab[player] then
CreatePet(player, Index)
else
local prevPet = tostring(tab[player])
tab[player]:Destroy()
tab[player] = nil
if prevPet ~= Index then
CreatePet(player, Index)
end
end
PetCreate:FireClient(player, tab[player])
end)

3 comments
This error is what it is,
Pet.PrimaryPartis missing, primary part should be the root part of the modelon line 39 put Pet.PrimaryPart = Pet:FindFirstChildWhichIsA("Part",true) or something like that for an easy fix
There is no primarypart. It is basically the main part for positioning or tweening of a model