So i am making a pet system for my game, and when i try to delete a pet, it gives me two errors. However, i cannot see why the error is giving “BPet” instead of the pets name. Any help would be appreciated!
1st Error:
"Infinite yield possible on `Players.Noobzilla1207.OwnedPets:WaitForChild("BPet")' "
2nd Error:
"Infinite yield possible on `Players.Noobzilla1207.OwnedPets:WaitForChild("Pet")' "
deletePetEvent.OnServerEvent:Connect(function(Player,petName)
local deletedPet,failedDeleting = pcall(function()
Player.OwnedPets:WaitForChild(petName .. "Pet"):Destroy()
Player.ActionValues.CurrentInventorySpace.Value -= 1
end)
if not deletedPet then
warn(failedDeleting)
end
end)
petImg.petImage.Activated:Connect(function()
if deleteDebounce == false and toggleDelete.deleting.Value == true and petImg.equipped.Value == false and petImg:FindFirstChild('CrossMark') then
deleteDebounce = true
script:FindFirstChild("PaperSound"):Play()
game:GetService('ReplicatedStorage').ServerEvents.deletePet:FireServer(petImg.Name)
petImg:Destroy()
wait(0.4)
deleteDebounce = false
end
end)
end
end
is the petImg name set to the correct thing because it looks like it’s just sending over the letter B rather than an actual pet name that’s stored in the player