Localizing Character Breaks Accessory Welds

In a FE place, If a character is parented to nil by the server, then parented back to the Workspace by its client, accessory welds will break. As soon as the player is re-parented to the Workspace by the server, hat welds are restored. This only occurs in a local server, team test, or live game server, testing with the play button in studio does not reproduce this

Repro: WeldBug.rbxl (13.3 KB)

4 Likes

Thanks for the good reproduce case, we will look into this. If you need a temporary workaround you can use this code to re-weld the accessories on the client.

function weldAttachments(attach1, attach2)
    local weld = Instance.new("Weld")
    weld.Part0 = attach1.Parent
    weld.Part1 = attach2.Parent
    weld.C0 = attach1.CFrame
    weld.C1 = attach2.CFrame
    weld.Parent = attach1.Parent
    return weld
end

function findFirstMatchingAttachment(model, name)
    for _, child in ipairs(model:GetChildren()) do
        if child:IsA('Attachment') and child.Name == name then
            return child
        elseif not child:IsA('Accoutrement') and not child:IsA('Tool') then -- don't look in hats or tools in the character
            local foundAttachment = findFirstMatchingAttachment(child, name)
            if foundAttachment then
                return foundAttachment
            end
        end
    end
end

local character = game.Players.LocalPlayer.Character
for _, obj in pairs(character:GetChildren()) do
    if obj:IsA("Accessory") then
        local handle = obj:FindFirstChild("Handle")
        if handle then
            local accoutrementAttachment = handle:FindFirstChildOfClass("Attachment")
            if accoutrementAttachment then
                local characterAttachment = findFirstMatchingAttachment(character, accoutrementAttachment.Name)
                if characterAttachment then
                    weldAttachments(characterAttachment, accoutrementAttachment)
                end
            end
        end
    end
end
4 Likes