Delete Pet Not Working

Basically, when I delete the pet, the frame stays there no matter what until I rejoin. The Delete Remote:

Events.Delete.OnServerEvent:Connect(function(player, petName, Amount)
	if not tonumber(Amount) then 
		return;
	end
	
	local Data = __DataB.GetData(player) and __DataB.GetData(player).Data;
	
	Amount = (tonumber(Amount) or 1)
	
	if Amount < 1 or Amount == nil or string.lower(tostring(Amount)) == "nan" then
		return;
	end
	local petExist = {false,false,0}
	for key, value in pairs(require(__Inventory.__Pets)) do
		if value.Name == petName then
			petExist[1] = true;
			break	
		end
	end
	for key, value in pairs(Data.Inventory.Pets) do
		if value.Name == petName then
			petExist[2] = true;
			petExist[3] = value.Amount;
			break	
		end
	end

	if not petExist[1] or not petExist[2] then
		return
	end
	
	if Amount <= petExist[3] then
		for key, value in pairs(Data.Inventory.Pets) do
			if value.Name == petName and value.Amount >= petExist[3] then
				if value.Amount - Amount == 0 then
					Data.Inventory.Pets[key] = nil;
					warn(Data.Inventory.Pets[key] or 'PET NO EXIST')
					warn(string.format("Deleted %d of %s", Amount, petName))
					game.ReplicatedStorage.Remotes.Events["Quick Update"]:FireClient(player, Data.Inventory.Pets)
					break
				else
					value.Amount -= Amount;
					warn(string.format("Deleted %d of %s", Amount, petName))
					game.ReplicatedStorage.Remotes.Events["Quick Update"]:FireClient(player, Data.Inventory.Pets)
					break
				end
			end
		end
	end
end)

My client inventory code:

local function inventoryCheck(pets)
	local S = MainGame.Inventory.Holder.Scrolling;

	local yes_it_exist = false;
	if pets then
		for key, value in S:GetChildren() do
			for k, v in pairs(pets) do
				if v.Name == value.Name then
					yes_it_exist = true
					warn(v.Name .. ' exists!')
					break
				end
			end
			if yes_it_exist == true then
				return true
			else
				if not value.Name == "UIGridLayout" and not value.Name == "Amount" then
					print(value.Name .. ' doesnt exist!')
					value:Destroy()
				end
				return true
			end
		end
	end
end
local function updatePets(Pets)
	local f = MainGame.Inventory.Holder.Scrolling
	inventoryCheck(Pets)
	for key, value in pairs(Pets) do
		if f:FindFirstChild(value.Name) then
			if f:FindFirstChild(value.Name):FindFirstChild("Amount") then
				f:FindFirstChild(value.Name):FindFirstChild("Amount").Value = value.Amount;
				f:FindFirstChild(value.Name).Click_Pet.MouseButton1Click:Connect(function()
					task.wait()
					MainGame.Inventory["Pet Selected"].Value = value.Name;
				end)
			end
		else
			local temp = require(script.Viewport):InventoryViewPoint({
				Name = value.Name;
				Parent = f;
			})
			f:FindFirstChild(value.Name).Click_Pet.Multiplier.Text = value.Perk .. 'x'
			local amount = Instance.new("NumberValue", temp)
			amount.Name = "Amount"
			amount.Value = value.Amount;
			f:FindFirstChild(value.Name).Click_Pet.MouseButton1Click:Connect(function()
				task.wait()
				MainGame.Inventory["Pet Selected"].Value = value.Name;
			end)
		end
	end
end

The weird issue is that it works fine, until I delete a pet. I have to delete it twice for the frame to actually disappear. If any more code is needed, let me know.