I’ve had this issue in the past with putting accessories in a viewport frame, and couldn’t ever find an effective solution so I wrote this function to make get placed properly on the client, not a large resource, but figured it would help out some people with things that require accessory behavior on the client.
function ClientVisualizeAccessory(Accessory, TargetCharacter)
if Accessory ~= nil and TargetCharacter ~= nil then
local Handle = Accessory.Handle
local Attachment = Handle:FindFirstChildOfClass("Attachment")
local AccessoryParts = {}
for i, v in ipairs(Accessory:GetDescendants()) do
if v:IsA("BasePart") then
table.insert(AccessoryParts,
{
Part = v,
Offset = Attachment.WorldCFrame:ToObjectSpace(v.CFrame)
}
)
end
end
local TargetAttachment = TargetCharacter:FindFirstChild(Attachment.Name, true)
for i, v in ipairs(AccessoryParts) do
v.Part.CFrame = TargetAttachment.WorldCFrame * v.Offset
end
end
end