I have been editing a fairly old ui one of my friends made that allows me to adjust the VertexColor and Texture of any accessory mesh on a person’s avatar, but the moment my character spawns in–my layered clothing disappears entirely. My other accessories remain fine, but my layered clothing is just–poof.
I will not share the rest of the script but this is the beginning part of the script I have. I feel like it’s close to where I think the issue might be. Some help could be appreciated!
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local InsertService = game:GetService("InsertService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local RemoteFolder = ReplicatedStorage.RemoteEvents.FaceAndAccessoryColors
local CachedLoadAsset = (function()
local CachedAssets = {}
return function(AssetId)
local Result
if CachedAssets[AssetId] then
Result = CachedAssets[AssetId]:Clone()
else
local Original = nil
local Success, Error = pcall(function()
Original = InsertService:LoadAsset(AssetId):GetChildren()[1]
end)
if Success then
CachedAssets[AssetId] = Original
Result = Original:Clone()
else
warn("Could not load asset: " .. Error)
end
end
return Result
end
end)()
Players.PlayerAdded:Connect(function(Player)
Player:GetPropertyChangedSignal("Character"):Connect(function()
local Character = Player.Character
if Character then
local Humanoid = Character.Humanoid --pls
if Humanoid.RigType == Enum.HumanoidRigType.R15 then
Character.ChildAdded:Connect(function(Child)
if Child:IsA("Accessory") then
if Child.Handle.ClassName == "MeshPart" then
RunService.Stepped:Wait()
if Child.Parent then
Child:Destroy()
end
end
end
end)
local Info
local Success, Error = pcall(function()
Info = Players:GetCharacterAppearanceInfoAsync(Player.UserId) --you cannot get the asset ID from the meshparts
end)
if Success then
Humanoid:RemoveAccessories()
for i, Asset in pairs(Info.assets) do
local AssetTypeName = Asset.assetType.name
if AssetTypeName == "Hat" or string.find(AssetTypeName, "Accessory") then
local ReplacementAsset = CachedLoadAsset(Asset.id)
if ReplacementAsset then
Humanoid:AddAccessory(ReplacementAsset)
end
end
end
else
warn("Could not get character appearance: " .. Error)
end
end
end
end)
end)