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

-- create part
local part = Instance.new("Part")
part.Size = Vector3.new(5, 1, 5)
part.Position = Vector3.new(0, 0.5, 0)
part.Anchored = true
part.TopSurface = Enum.SurfaceType.Smooth
part.BrickColor = BrickColor.new("Toothpaste")
-- create decal
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Top
decal.Parent = part
-- create sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- oof
sound.Parent = part
-- define faces
local happyFace = "http://www.roblox.com/asset/?id=26424652"
local sadFace = "http://www.roblox.com/asset/?id=147144198"
decal.Texture = happyFace
-- touched event
local cooldown = false
part.Touched:Connect(function(hit)
if not cooldown then
if hit and hit.Parent then
cooldown = true
sound:Play()
decal.Texture = sadFace
task.wait(1)
decal.Texture = happyFace
task.wait(0.2)
cooldown = false
end
end
end)
-- add to workspace
part.Parent = workspace

Summary

Properties

Properties inherited from FaceInstance

Properties

Color3

read parallel

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.

Code Samples

Decal Color3

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Size = Vector3.new(10, 10, 1)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Transparency = 1
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Front
decal.Texture = "http://www.roblox.com/asset/?id=1145367640" -- white circle
decal.Parent = part
part.Parent = workspace
local redTween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
{ Color3 = Color3.new(1, 0, 0) }
)
local greenTween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
{ Color3 = Color3.new(0, 1, 0) }
)
local blueTween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
{ Color3 = Color3.new(0, 0, 1) }
)
while true do
redTween:Play()
redTween.Completed:Wait()
greenTween:Play()
greenTween.Completed:Wait()
blueTween:Play()
blueTween.Completed:Wait()
end

LocalTransparencyModifier

hidden
not replicated
read parallel

Acts as a multiplier for the decal's Decal.Transparency property. The effects are only visible to the Players.LocalPlayer.

This property should be used in situations where Decal.Transparency is being set by a different script. The benefit of LocalTransparencyModifier is that it can be changed without concern for the original Decal.Transparency of the Decal

When LocalTransparencyModifier is set to 1, the Decal will be completely invisible regardless of its original transparency. When it is set to 0, the decal's rendered transparency will match the Decal.Transparency value. The formula for this is:


Displayed Transparency = Transparency + ((1 - Transparency) * LocalTransparencyModifier)

Note, this property should be used on the client only and will not replicate to the server.

For a variant of this property for BaseParts, see BasePart.LocalTransparencyModifier.

Texture

read parallel

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.

Code Samples

Changing Decal Texture

-- create part
local part = Instance.new("Part")
part.Size = Vector3.new(5, 1, 5)
part.Position = Vector3.new(0, 0.5, 0)
part.Anchored = true
part.TopSurface = Enum.SurfaceType.Smooth
part.BrickColor = BrickColor.new("Toothpaste")
-- create decal
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Top
decal.Parent = part
-- create sound
local sound = Instance.new("Sound")
sound.SoundId = "rbxasset://sounds/uuhhh.mp3" -- oof
sound.Parent = part
-- define faces
local happyFace = "http://www.roblox.com/asset/?id=26424652"
local sadFace = "http://www.roblox.com/asset/?id=147144198"
decal.Texture = happyFace
-- touched event
local cooldown = false
part.Touched:Connect(function(hit)
if not cooldown then
if hit and hit.Parent then
cooldown = true
sound:Play()
decal.Texture = sadFace
task.wait(1)
decal.Texture = happyFace
task.wait(0.2)
cooldown = false
end
end
end)
-- add to workspace
part.Parent = workspace

Transparency

read parallel

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.

Code Samples

Fading Decal

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Size = Vector3.new(10, 10, 1)
part.Position = Vector3.new(0, 5, 0)
part.Anchored = true
part.Transparency = 1
local decal = Instance.new("Decal")
decal.Face = Enum.NormalId.Front
decal.Texture = "http://www.roblox.com/asset/?id=699259085" -- roblox logo
decal.Parent = part
part.Parent = workspace
local tween = TweenService:Create(
decal,
TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true),
{ Transparency = 1 }
)
tween:Play()

ZIndex

read parallel

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 a 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:

Methods

Events