Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local addAccessory
- local removeAccessory
- do -- Appearance adding / removing
- local function hasTag(parent, tag)
- local tagValue = parent:FindFirstChild("AccessoryTag")
- if tagValue and tagValue.ClassName == "StringValue" then
- return tagValue.Value == tag
- end
- return false
- end
- local function addTag(parent, tag)
- local oldTag = parent:FindFirstChild("AccessoryTag")
- if oldTag then
- oldTag.Value = tag
- else
- local newTag = Instance.new("StringValue")
- newTag.Name = "AccessoryTag"
- newTag.Value = tag
- newTag.Parent = parent
- end
- end
- local function weld(attachment0, attachment1)
- local part0 = attachment0.Parent
- local part1 = attachment1.Parent
- local weld = Instance.new("Weld")
- weld.Part0 = part0
- weld.Part1 = part1
- weld.C0 = attachment0.CFrame
- weld.C1 = attachment1.CFrame
- weld.Name = "["..attachment0.Name.." | "..attachment1.Name.."]"
- weld.Parent = part1
- return weld
- end
- function addAccessory(character, accessory, tag)
- local accessoryAttachment = accessory:FindFirstChildOfClass("Attachment")
- if not accessoryAttachment then
- for _, child in pairs(accessory:GetChildren()) do
- if child:IsA("BasePart") then
- accessoryAttachment = child:FindFirstChildOfClass("Attachment")
- if accessoryAttachment then break end
- end
- end
- end
- if accessoryAttachment then
- local characterAttachment = character:FindFirstChild(accessoryAttachment.Name, true)
- if characterAttachment and characterAttachment.ClassName == "Attachment" then
- accessory.Parent = character
- weld(characterAttachment, accessoryAttachment)
- if type(tag) == "string" then
- addTag(accessory, tag)
- end
- else
- warn("Appearance | attachment missing in character: "..tostring(accessoryAttachment))
- accessory:Destroy()
- end
- else
- warn("Appearance | attachment missing for accessory: "..tostring(accessory))
- accessory:Destroy()
- end
- end
- function removeAccessory(character, tag)
- for _, child in pairs(character:GetChildren()) do
- if child:IsA("Accoutrement") then
- if hasTag(child, tag) then
- child:Destroy()
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement