Problem: Slow cloning images from inventory
What I need:
Apologies for un-edited video
What I have:
Apologies for un-edited video
Tried: Reducing customization of cloned TextButton
Idea: Use an API of my own to get the marketplace info
Script:
local button = script.Parent
local inventoryFrame = script.Parent.Parent.Parent.InventoryFrame
local accessoryFrame = script.Parent.Parent.Parent.AccessoryFrame
local avatarService = game:GetService("AvatarEditorService")
local marketPlaceService = game:GetService("MarketplaceService")
local marketplace = game:GetService("MarketplaceService")
local sortByButton = script.Parent.Parent.Parent.SwitchFilterTypeInventory
local count = 0
avatarService:PromptAllowInventoryReadAccess()
local result = avatarService.PromptAllowInventoryReadAccessCompleted:Wait()
local function creation(assetTypes)
for _,UIObject in pairs(inventoryFrame:GetChildren()) do
if UIObject then
if UIObject:IsA("ImageButton") then
UIObject:Destroy()
end
end
end
local pagesObject = avatarService:GetInventory(assetTypes)
local currentPage = pagesObject:GetCurrentPage()
for _,accessory in pairs(currentPage) do
local item = accessory
local accessoryInfo = marketplace:GetProductInfo(accessory.AssetId)
local accessoryName = accessoryInfo.Name
local accessoryId = accessory.AssetId
local accessoryType = accessory.AccessoryType
local infoTable = {
Name = accessoryName,
Id = accessoryId,
Type = accessoryType,
}
local info = marketPlaceService:GetProductInfo(accessoryId)
local newImageButton = game.ReplicatedStorage.CloneForAccessory:Clone()
newImageButton.AssetId.Value = accessoryId
newImageButton.AssetType.Value = tostring(infoTable.Type)
newImageButton.Image = "rbxthumb://type=Asset&id=" .. accessoryId .. "&w=420&h=420"
newImageButton.Parent = script.Parent.Parent.Parent.InventoryFrame
newImageButton.Name = accessoryName .. "_Accessory"
newImageButton.BackgroundTransparency = 0.5
newImageButton.BackgroundColor3 = Color3.fromRGB(255,255,255)
newImageButton.BorderSizePixel = 0
newImageButton.Size = UDim2.new(0,0)
local limitedTag = newImageButton.IsLimited
local verifiedTag = newImageButton.IsVerified
if info.ProductType == "Collectible Item" or info.IsLimited == true or info.IsLimitedUnique == true then
limitedTag.Visible = true
end
if info.Creator.HasVerifiedBadge == true then
verifiedTag.Visible = true
end
print(infoTable)
end
end
if result == Enum.AvatarPromptResult.Success then
local assetTypes = {
Enum.AvatarAssetType.BackAccessory,
Enum.AvatarAssetType.ShoulderAccessory,
Enum.AvatarAssetType.WaistAccessory,
Enum.AvatarAssetType.Hat,
Enum.AvatarAssetType.Face,
Enum.AvatarAssetType.FaceAccessory,
Enum.AvatarAssetType.HairAccessory,
Enum.AvatarAssetType.NeckAccessory,
}
creation(assetTypes)
end
sortByButton.MouseButton1Click:Connect(function()
if count == 0 then
count = count + 1
sortByButton.Text = "Sort By: All"
local assetTypes = {
Enum.AvatarAssetType.BackAccessory,
Enum.AvatarAssetType.ShoulderAccessory,
Enum.AvatarAssetType.WaistAccessory,
Enum.AvatarAssetType.Hat,
Enum.AvatarAssetType.Face,
Enum.AvatarAssetType.FaceAccessory,
Enum.AvatarAssetType.HairAccessory,
Enum.AvatarAssetType.NeckAccessory,
}
creation(assetTypes)
elseif count == 1 then
count = count + 1
sortByButton.Text = "Sort By: Hat"
local assetTypes = {
Enum.AvatarAssetType.Hat,
}
creation(assetTypes)
count = 0
else
count = 0
end
end)
button.MouseButton1Click:Connect(function()
accessoryFrame.Visible = false
inventoryFrame.Visible = true
sortByButton.Visible = true
inventoryFrame.Size = UDim2.new(0.603, 0,0.684, 0)
end)
What Im cloning: