I am making this topic because I would like to know if there is a method to detect if a player is using accessories created by a user or a group so it can be detected and removed in-game using the :Destroy function.
I have tried using MarketplaceService API specifically to get creator information at GetProductInfo dictionary. However, this didn’t work and I am unsure how I can make an accurate and precise script… Here is the script I tried to produce:
local groupId = 4740060 -- Replace with the Group ID of the group whose accessories you want to remove
local MarketplaceService = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(character)
-- Wait for all accessories to load
character.ChildAdded:Wait()
for _, accessory in pairs(character:GetChildren()) do
if accessory:IsA("Accessory") then
local accessoryId = accessory.AccessoryType -- Get the ID of the accessory
-- Use pcall to handle any potential errors
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(accessoryId, Enum.InfoType.Asset)
end)
if success and productInfo.Creator.CreatorType == "Group" and productInfo.Creator.CreatorTargetId == groupId then
accessory:Destroy() -- Remove the accessory if it was made by the specified group
end
end
end
end)
end)
accessory.AccessoryType is not how you get the Accessories’s AssetIDs.
this is how you can do it
local HumanoidDescription = Character.Humanoid:WaitForChild("HumanoidDescription")
local accessories = HumanoidDescription:GetAccessories(true)
for _,accessory in pairs(accessories) do
local AssetId = accessory.AssetId -- Accessory's AssetID
end
--[Services]--
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
--[Group ID]--
local groupId = 4740060 -- Replace with the Group ID of the group whose accessories you want to remove
--[Event]--
Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(character)
local humanoidDescription = character:WaitForChild("Humanoid"):WaitForChild("HumanoidDescription")
local accessories = humanoidDescription:GetAccessories(true)
for _, accessoryData in pairs(accessories) do
local assetId = accessoryData.AssetId -- Accessory's AssetID
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(assetId, Enum.InfoType.Asset)
end)
if success and productInfo.Creator.CreatorType == "Group" and productInfo.Creator.CreatorTargetId == groupId then
-- Find the actual accessory instance in the character
for _, accessoryInstance in pairs(character:GetChildren()) do
if accessoryInstance:IsA("Accessory") and accessoryInstance.Name == accessoryData.Name then
accessoryInstance:Destroy() -- Remove the accessory if it was made by the specified group
end
end
end
end
end)
end)
--[Services]--
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
--[Group ID]--
local groupId = 4740060
--[Event]--
Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(character)
local humanoidDescription = character:WaitForChild("Humanoid"):WaitForChild("HumanoidDescription")
local accessories = humanoidDescription:GetAccessories(true)
for _, accessoryData in pairs(accessories) do
local assetId = accessoryData.AssetId -- Accessory's AssetID
local success, productInfo = pcall(function()
return MarketplaceService:GetProductInfo(assetId, Enum.InfoType.Asset)
end)
if success and productInfo.Creator.CreatorType == "Group" and productInfo.Creator.CreatorTargetId == groupId then
local Accessory = game:GetService("InsertService"):LoadAsset(assetId):GetChildren()[1]
local AccessoryName = Accessory.Name
Accessory:Destroy()
if character:FindFirstChild(AccessoryName) then
character[AccessoryName]:Destroy()
end
end
end
end)
end)