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!
"Infinite yield possible on `Players.Noobzilla1207.OwnedPets:WaitForChild("BPet")' "
"Infinite yield possible on `Players.Noobzilla1207.OwnedPets:WaitForChild("Pet")' "
local deletedPet,failedDeleting = pcall(function()
Player.OwnedPets:WaitForChild(petName .. "Pet"):Destroy()
Player.ActionValues.CurrentInventorySpace.Value -= 1
if not deletedPet then
You can try using FindFirstChild()
Or check if what you’re trying to find even exists
i have done that. when i do, it gives me the error “ServerScriptService.NormalValues:328: attempt to index nil with ‘Destroy’”
Then what you’re trying to find doesn’t exist, lol.
I don’t see nothing called Pet or BPet my boy
oh wait. i just realized i meant to say “Player.ActionValues.OwnedPets…”
sorry for the trouble everyone
It is fine, next time try to check if the objects even exist when you encounter that error
wait im so dumb. “OwnedPets” isnt even in action values. its in the player…
so why is the script getting “BPet” instead of the pet’s name?
what’s firing the event, because it seems that it’s just returning the petName as “B” rather than what it’s supposed to
a local script in a gui somewhere. i can get it if you need it.
can i see the script because im assuming it’s just sending the wrong thing to the server
if deleteDebounce == false and toggleDelete.deleting.Value == true and petImg.equipped.Value == false and petImg:FindFirstChild('CrossMark') then
deleteDebounce = true
deleteDebounce = false
(theres more if you need it)
:WaitForChild(item, math.huge) fixes this.
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
Do you set the name to petImg? If you do can you show me the section of the code where it does.
for _, petImg in pairs(petListFrame:GetChildren()) do
if petImg:IsA("ImageLabel") then
if petImg.equipped.Value == true then
No could you share a part of the code where you set petImg.Name to something, the problem should be there