SpecialMesh

Show Deprecated

The SpecialMesh is an object that allows developers to provide a standard template or user uploaded mesh to a BasePart.

What does a SpecialMesh do?

The SpecialMesh object applies a mesh to a BasePart depending on the the SpecialMesh.MeshType property. A number of options are available.

  • Brick - A block shape, equivalent to a BlockMesh
  • Cylinder - A cylinder, identical to a Part with a Part.Shape of 'Cylinder'
  • FileMesh - A user uploaded Mesh, equivalent to FileMesh that a texture can be applied to using the FileMesh.TextureId property
  • Head - A character head shape
  • Sphere - A sphere shape, similar to a Part with a Part.Shape of 'Ball' but can be freely resized on all axis
  • Wedge - A wedge shape, identical to a WedgePart
  • Torso - A block with sloped sides, due to be deprecated

Note, each SpecialMesh.MeshType will scale differently when using DataModelMesh.Scale, for more information on this please see the page on DataModelMesh.Scale. The SpecialMesh object also exposes the DataModelMesh.Offset property.

It is important to remember that when using a SpecialMesh, only the appearance of a part changes. The collision model of the part remains the same. For example, a character will not be able to walk correctly over a mesh as the mesh geometry is not taken into account.

SpecialMesh or MeshPart?

There are currently two ways of using a developer created mesh. They are using a SpecialMesh with the SpecialMesh.FileType set to 'FileMesh', or by using a MeshPart. Although, on the whole, the MeshPart object has superseded the SpecialMesh there are some differences developers should be aware of.

In most, but not all cases, using a MeshPart is more suitable. As MeshParts are a relatively new feature however, developers should expect some of the above behaviour to change.

Uploading a custom mesh

Although a developer uploaded mesh can be used on a SpecialMesh, meshes can currently only be be uploaded using MeshParts or the game explorer. For more information, see Meshes.

Code Samples

Mesh VertexColor

1local TweenService = game:GetService("TweenService")
2
3-- instance a part and a mesh
4local part = Instance.new("Part")
5part.Size = Vector3.new(4, 8, 4)
6part.Position = Vector3.new(0, 4, 0)
7part.Anchored = true
8part.CanCollide = false
9
10local mesh = Instance.new("SpecialMesh")
11mesh.MeshType = Enum.MeshType.FileMesh
12mesh.MeshId = "rbxassetid://1086413449"
13mesh.TextureId = "rbxassetid://1461576423"
14mesh.Offset = Vector3.new(0, 0, 0)
15mesh.Scale = Vector3.new(4, 4, 4)
16mesh.VertexColor = Vector3.new(1, 1, 1)
17mesh.Parent = part
18
19-- parent part to workspace
20part.Parent = workspace
21
22-- create tweens
23local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
24local blackTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 0) })
25local redTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 0, 0) })
26local greenTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 1, 0) })
27local blueTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(0, 0, 1) })
28local resetTween = TweenService:Create(mesh, tweenInfo, { VertexColor = Vector3.new(1, 1, 1) })
29
30-- animate
31while true do
32 blackTween:Play()
33 blackTween.Completed:Wait()
34 redTween:Play()
35 redTween.Completed:Wait()
36 greenTween:Play()
37 greenTween.Completed:Wait()
38 blueTween:Play()
39 blueTween.Completed:Wait()
40 resetTween:Play()
41 resetTween.Completed:Wait()
42 task.wait()
43end
Mesh Offset and Scale

1local TweenService = game:GetService("TweenService")
2
3-- instance a part and a mesh
4local part = Instance.new("Part")
5part.Size = Vector3.new(4, 8, 4)
6part.Position = Vector3.new(0, 4, 0)
7part.Anchored = true
8part.CanCollide = false
9
10local mesh = Instance.new("SpecialMesh")
11mesh.MeshType = Enum.MeshType.FileMesh
12mesh.MeshId = "rbxassetid://1086413449"
13mesh.TextureId = "rbxassetid://1461576423"
14mesh.Offset = Vector3.new(0, 0, 0)
15mesh.Scale = Vector3.new(4, 4, 4)
16mesh.Parent = part
17
18-- selection box to show part extents
19local box = Instance.new("SelectionBox")
20box.Adornee = part
21box.Parent = part
22
23-- parent part to workspace
24part.Parent = workspace
25
26-- animate offset and scale with a tween
27local tween = TweenService:Create(
28 mesh,
29 TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true, 0),
30 { Scale = Vector3.new(1, 1, 1), Offset = Vector3.new(0, 3, 0) }
31)
32
33tween:Play()

Summary

Properties

Determines the type of mesh that will be applied to the BasePart the SpecialMesh is parented to.

Events

Methods

Properties

MeshType

The mesh that the SpecialMeshobject applies to the BasePart depends on the MeshType property. A number of options are available.

  • Brick - A block shape, equivalent to a BlockMesh
  • Cylinder - A cylinder, identical to a Part with a Part.Shape of 'Cylinder'
  • FileMesh - A user uploaded Mesh, equivalent to FileMesh that a texture can be applied to using the FileMesh.TextureId property
  • Head - A character head shape
  • Sphere - A sphere shape, similar to a Part with a Part.Shape of 'Ball' but can be freely resized on all axis
  • Wedge - A wedge shape, identical to a WedgePart
  • Torso - A block with sloped sides, due to be deprecated

Note, each MeshType will scale differently when using DataModelMesh.Scale, for more information on this please see the page on DataModelMesh.Scale.

Events

Methods