How to use .Created to remove accessories from an avatar that were made before a certain year?

Pretty simple question, how do I use .Created in a script to remove accessories from players joining that were created before a certain year? I know I’m going to need to use ApplyDescription to humanoids and all, but I’m just not sure how to put the script into fruition.

You could use the character’s HumanoidDescription to find the IDs for every accessory, check their creation, delete the ones you don’t want and apply it again.

The script would be something like this:

local MinYear = 2020
local Char -- This will be the player's character

local MarketplaceService = game:GetService("MarketplaceService")

-- Get all the accessories we need
local Description = Char.Humanoid:GetAppliedDescription()
local Accessories = Description:GetAccessories(true)
local ToRemove = {} -- Here we will keep accessories we don't want
-- Loop through accessories
for i, accessory in Accessories do
	if tonumber(string.split(MarketplaceService:GetProductInfo(accessory.AssetId).Created,"-")[1]) < MinYear then
		table.insert(ToRemove,accessory)
	end
end

-- Remove all unwanted accessories
for _, accessory in ToRemove do
	-- This substitues the ID of the accessory in the list with an empty string, effectively deleting it
	local AccessoryType = string.sub(tostring(accessory.AccessoryType),20,-1)
	Description[AccessoryType.."Accessory"] = string.gsub(Description[AccessoryType.."Accessory"],tostring(accessory.AssetId),"")
end

Char.Humanoid:ApplyDescription(Description)

Hope this helps!

I’m not exactly sure what’s going on in this script, but I don’t think this even is able to function. I don’t see anywhere that the script even uses MarketplaceService to use the asset ID to find the creation date of the asset.

I’ve been trying to figure this problem out, and this is what I have gotten so far as a StarterPlayerScript:

local MS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer -- Get the local player

-- Function to get character appearance information
local function getAppearanceInfo()
	local userId = player.UserId -- Get the UserId of the local player
	local success, info = pcall(function() 
		return game.Players:GetCharacterAppearanceInfoAsync(userId)
	end)

	if success then
		for _, asset in ipairs(info['assets']) do
			local AssetId = asset.id
			print(AssetId) -- Printed Asset IDs will appear in the output window
		end
	else
		warn("Failed to get character appearance info: " .. tostring(info))
	end
end

-- Call the function when the player joins
getAppearanceInfo()

This gets the asset IDs of every asset currently on the player and pastes the IDs into output. I’m just trying to figure out how to get the creation date right now from the IDs gathered by this script.

I don’t really know anything about dictionaries or tables so maybe I’m just missing something about your script.