Simple way to convert SpecialMesh into MeshPart?

I want a way to detect SpecialMeshes in a model and convert them into MeshParts, preserving the position and scale. Is there a simple way to do this, or do I have to manually consider the MeshId, MeshType, etc.? If so, how would I determine the size of the MeshPart? If it wasn’t clear, I am not asking how to convert a SpecialMesh to a MeshPart through studio, I am asking for a function that should work for arbitrary meshes.

2 Likes

The issue with SpecialMeshes is that you can’t get the actual size of the mesh and it uses its parent part’s size only for physics. You will have to do this manually.

you can copy the mesh ID and simply put the ID into a MeshPart

local model = game.Workspace.Model
local children = model:GetChildren()

for i = 1, #children do
    if(children[i]:IsA("SpecialMesh")then
        local meshPart = Instance.new("MeshPart")
        meshPart.MeshId = children[i].MeshId
        meshPart.Parent = children[i].Parent
        children[i]:Destroy()
    end)
end

this would have a lot of latency though, if your just switching IDs, it would be better to keep
copies of the Mesh in replicated storage and then cloning from there.

1 Like

Hello. First of all, you cannot transform any SpecialMesh into a MeshPart. You might want to transform a Sphere, Brick or Cylinder MeshType into a regular part whose shape is a Ball, Block or Cylinder respectively. You would have to consider scale here.

About converting a FileMesh into MeshPart through a script, I’m afraid it is not possible:

The DataModelMesh/MeshId property of a SpecialMesh can be changed by a Script or LocalScript during runtime. The MeshPart.MeshId property of a MeshPart can not.

Also, I’ve tested it in studio and sadly, no, you can’t use the command bar to do so either. Right now, the only option is to set the MeshParts IDs manually in studio.

1 Like

Yes you can. Copy and paste the MeshId from the SpecialMesh into the MeshId of a MeshPart. Conversion can’t be done programmatically, but by hand yes it can. With regards to retaining size, you simply need to look at the SpecialMesh Scale then multiply the X, Y and Z parts of Size by the X, Y and Z of the SpecialMesh Scale.

5 Likes

Dang, this really sucks since I was hoping to convert accessories on player characters to MeshParts (since Roblox still uses SpecialMeshes for them), but now it looks like you can’t make arbitrary MeshParts at runtime.
Thanks for the help everyone, I was looking for a way to do this programmatically, if it wasn’t clear from the post.

For anyone looking into this even after 4 years old, this is possible now through this: