Decal

Show Deprecated

The Decal object is an object which applies an image to a face of a BasePart.

How does a Decal work?

A Decal will apply an image to the BasePart it is parented to. The surface this image is applied to is dependent on the FaceInstance.Face property. The size of the decal is dependent on the size of the face, meaning the size and aspect ratio of a decal can be changed by changing its parent's BasePart.Size.

The image a Decal applies is determined by its Decal.Texture property. Images can be uploaded to Roblox provided they adhere to the community guidelines.For information on how to upload images, see Textures and Decals.

Alternatives to Decals

Although Decals have a wide variety of applications, in some cases developers may wish to pick one of the following classes instead.

  • For repeated tiled textures, the Texture object should be used
  • To apply GUI elements, the SurfaceGui object should be used
  • If the effect of lighting on the image needs to be altered, the SurfaceGui object should be used

Code Samples

Changing Decal Texture

1-- create part
2local part = Instance.new("Part")
3part.Size = Vector3.new(5, 1, 5)
4part.Position = Vector3.new(0, 0.5, 0)
5part.Anchored = true
6part.TopSurface = Enum.SurfaceType.Smooth
7part.BrickColor = BrickColor.new("Toothpaste")
8
9-- create decal
10local decal = Instance.new("Decal")
11decal.Face = Enum.NormalId.Top
12decal.Parent = part
13
14-- create sound
15local sound = Instance.new("Sound")
16sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- oof
17sound.Parent = part
18
19-- define faces
20local happyFace = "http://www.roblox.com/asset/?id=26424652"
21local sadFace = "http://www.roblox.com/asset/?id=147144198"
22
23decal.Texture = happyFace
24
25-- touched event
26local cooldown = false
27part.Touched:Connect(function(hit)
28 if not cooldown then
29 if hit and hit.Parent then
30 cooldown = true
31 sound:Play()
32 decal.Texture = sadFace
33 task.wait(1)
34 decal.Texture = happyFace
35 task.wait(0.2)
36 cooldown = false
37 end
38 end
39end)
40
41-- add to workspace
42part.Parent = workspace

Summary

Properties

The Color3 tint of the Decal.

The ContentId of the image to be applied by the Decal.

Determines the transparency of the Decal with 0 being completely opaque and 1 completely transparent.

Determines the rendering order when multiple Decals are assigned the same face.

Events

Methods

Properties

Color3

The Color3 tint of the Decal.

Developers should note that this property only sets the tint of the decal, rather than the color. This means, unless the image associated with the Decal was originally white (RGB = 1,1,1) then the color cannot be freely changed using this property.

By reducing the RGB properties of Color3 in union, developers can make a decal darker.

Texture

The Content ID of the image to be applied by the Decal.

How can I upload a Decal?

Images can be uploaded to Roblox provided they adhere to the community guidelines. For information on how to upload images, see Textures and Decals.

How to find do I find a Decal's Content ID?

Unlike with Sound and Animation objects, the Content ID of a Decal is not the same as the number in the URL. There are two main ways of finding the Content ID of a Decal:

  • Paste the URL into the Texture property in Roblox Studio. Roblox will automatically update the property to the correct Content ID. Note this only works in Roblox Studio and cannot be done from Scripts or while the game is running.
  • Insert the Decal into the game, this is generally done through the Toolbox under 'My Decals'. The Content ID can be found in the decal that is inserted. Note, InsertService:LoadAsset() can also be used if developers wish to automate this method.

Transparency

Determines the transparency of the Decal with 0 being completely opaque and 1 completely transparent.

Note, Decals also respect the transparency of the original image file uploaded to Roblox. This means transparency can be changed prior to uploading to Roblox, and without the need to use the Transparency property.

Decal.LocalTransparencyModifier acts as a multiplier for the Decal's transparency and should be used when the transparency of the decal is likely to be changed by another script, as is the case with player Characters.

For BaseParts, see BasePart.Transparency.

ZIndex

ZIndex determines the order in which decals on the same Face of a BasePart are rendered. Decals are rendered in ascending priority order, where lower values are rendered first. Therefore, a decal with a higher ZIndex renders later (and on top of) other Decals with lower ZIndex.

The range of valid values is -MAX_INT to MAX_INT, inclusive (2,147,483,647 or (2^31 - 1)). If you are unsure if you will need to layer an decal between two already-existing decals in the future, it can be a good idea to use multiples of 100, i.e. 0, 100, 200. This ensures a large gap of ZIndex values you can use for elements rendered in-between other elements.

See also:

Events

Methods