Asset ban Question?

I am fairly new to scripting so don’t judge me too much if this is a bad question. Is it possible to ban a certain part of the catalog (back accessories) in your game? If it is possible how would one go about doing this task? I know you can ban certain items, but I really don’t want to ban every back accessory on Roblox. If the question does not make sense, feel free to ask for clarification. Thank you in advance.

2 Likes

You could just make an array of the id’s, then check and make sure the accessory isn’t one of them

1 Like

Yes. Every accessory (if made right) will have a hierarchy in this fashion:

Accessory accessory
    Part Handle
        Attachment xAttachment

You want to focus on that xAttachment. The x is just a variable, since hats require an attachment name matching one in the character to be attachedproperly. In your case, your example was that you wanted to remove back accessories, so you’d be looking for accessories with a BodyBackAttachment instance in their handles.

Although you can handle this in many ways (including with the recursive argument of FindFirstChild), I prefer to be certain about what I’m doing, so I take a long route that ensures I’m looking at an attachment object. That’s where I use FindFirstChildOfClass.

Here’s a code sample that can remove BodyBackAttachments:

-- You could use string manipulation at some point to avoid writing
-- out "Attachment" per attachment type, potentially.
local BANNED_ACCESSORY_TYPES = {"BodyBackAttachment"}

for _, accessory in ipairs(humanoid:GetAccessories()) do
    -- We'll assume any and all accessories are constructed properly and not
    -- account for nonexistent handles.
    local attachment = accessory.Handle:FindFirstChildOfClass("Attachment")
    if attachment and table.find(BANNED_ACCESSORY_TYPES, attachment.Name) then
        accessory:Destroy()
    end
end
6 Likes

You could also check for anything parenting to HumanoidRootPart under the torso, most back accessories go there, some aren’t even classified under that category, so that’s something to keep in mind.

No, because accessories don’t get parented to the HumanoidRootPart, they are parented to the character model. The HumanoidRootPart only has root-based attachments which aren’t used by accessories because that defeats the purpose of what aesthetic value accessories are meant to give.

Back accessories are still parented under the character. It uses attachments from the UpperTorso and LowerTorso when attaching, such as BodyBackAttachment for wings. Those don’t come from the HumanoidRootPart. A character’s root is really only meant for internal purposes while anything aesthetic is applied to the actual limbs of the character.

GetAccessories should return a table of all Accoutrements being worn by the player at the time. If any hats are parented to the HumanoidRootPart, then that’s either a problem of implementation (I’m not sure if, beyond welds, accessories even work there) or an issue that someone needs to be told of.

1 Like