1. The Goal
I am attempting to construct a simple local plugin for rigging characters, converting accessories into MeshPart, organizing them in folders and welding them. This is to aid in rigging up characters and keeping them clean and organized.
2. The Main Issue
But upon testing, the plugin results in this error:
The current thread cannot write 'MeshId' (lacking capability NotAccessible)
This error is referring to this line of code: meshPart.MeshId = meshId
I am aware this error occurs because Roblox restricts changing MeshId dynamically because it affects the collision model, which can’t be recalculated safely during runtime.
But what I’m trying to wrap my head around is how someone bypassed this issue? See, I’m primarily making this plugin to be a better version of the Special Mesh to Mesh Part plugin by @TheGrimDeathZombie, with extra features personally to help me with setting up rigs for animations. The plugin does exactly what I can’t get to work. Convert a SpecialMesh to a MeshPart
3. Attempted Solutions
- I’ve attempted to use the
InsertService:CreateMeshPartAsync()but with no luck, as I’d need to own the MeshAsset to make it work. - I have consulted the documentation for solutions, but no luck either.
As a result, I’m at a stopping point and can’t find how to fix this issue. Is there a solution to this?
for _, part in ipairs(accessory:GetChildren()) do
if part:IsA("BasePart") then
local sm = part:FindFirstChildOfClass("SpecialMesh")
if sm then
local meshId = sm.MeshId
local texId = sm.TextureId
local worldC0 = part.CFrame
local worldSize = part.Size
-- ensure a Folder named after the body part exists
local partFolder = bodyPart:FindFirstChild(bodyPart.Name)
if not partFolder then
partFolder = Instance.new("Folder")
partFolder.Name = bodyPart.Name
partFolder.Parent = bodyPart
end
-- create MeshPart instead of Part + SpecialMesh
local meshPart = Instance.new("MeshPart")
meshPart.Name = part.Name
meshPart.Size = worldSize
meshPart.MeshId = meshId
meshPart.TextureID = texId
meshPart.CanCollide = false
meshPart.Anchored = false
meshPart.CFrame = worldC0
meshPart.Transparency = part.Transparency
meshPart.Color = part.Color
meshPart.Material = part.Material
meshPart.Parent = partFolder
-- ensure a Welds folder
local weldsFolder = bodyPart:FindFirstChild("Welds")
if not weldsFolder then
weldsFolder = Instance.new("Folder")
weldsFolder.Name = "Welds"
weldsFolder.Parent = bodyPart
end
-- weld the MeshPart to the body part
local weld = Instance.new("WeldConstraint")
weld.Name = part.Name .. "_Weld"
weld.Part0 = bodyPart
weld.Part1 = meshPart
weld.Parent = weldsFolder
end
end
end