local petModel = pets:FindFirstChild(chosenPet.petName):Clone() petModel:PivotTo(CFrame.new(0, 0, 0)) petModel.Parent = eggViewport local cameraPet = Instance.new("Camera") cameraPet.Parent = eggViewport cameraPet.CFrame = CFrame.new(0,0, -3.3) * CFrame.Angles(0, math.rad(180), 0) eggViewport.CurrentCamera = cameraPet tweenService:Create(eggViewport, TweenInfo.new(0.7), {Size = UDim2.new(0.236, 0,0.494, 0)}):Play() eggViewport.NameLabel.Text = chosenPet.petName eggViewport.NameLabel.Visible = true eggViewport.RarityLabel.Text = chosenPet.Rarity eggViewport.RarityLabel.Visible = true task.wait(1.5) tweenService:Create(eggViewport, TweenInfo.new(0.3), {Size = UDim2.fromScale(0, 0)}):Play() task.wait(0.3) eggViewport.NameLabel.Visible = false eggViewport.RarityLabel.Visible = false for _, v in pairs(player:GetChildren()) do if v:IsA("ScreenGui") or v ~= eggSystemSS then v.Enabled = true end end
end
Without having more context to your code, it's hard to judge what exactly is going on. From the error stated in your title, it appears that local petModel = pets:FindFirstChild(chosenPet.petName):Clone()
is causing your error. To narrow it down, the children of pets
does not contain the pet chosenPet.petName
, causing it to be nil, which then causes your error.
To try and fix this, I suggest printing chosenPet.petName
and see what you get from that, then if that seems correct, (make sure you are in studio) print pets:GetChildren()
which will return of all the child objects under pets
.
Just to confirm, pets
is an object in your explorer/game, correct? If pets
is a table, the fix above is wrong, and you will need to supply some context code as to what exactly pets
is.