MaterialService

Show Deprecated
Not Creatable
Service

MaterialService is the game service responsible for managing materials. It is the container for global MaterialVariant instances. MaterialVariant can be child or descendant of MaterialService. For each base Material type, MaterialService internally keeps a set of MaterialVariant references. MaterialVariant.Name is the key to access it. The MaterialVariant.Name and MaterialVariant.BaseMaterial are combined to work as an identifier. If more than one MaterialVariant object has the same name and BaseMaterial under MaterialService, only one of them can be used.

MaterialService has some (Material)Name properties. Assigning a MaterialVariant Name replaces the built-in material with the specified MaterialVariant. If the MaterialService can't find a matching MaterialVariant, it falls back to built-in material. Note BaseMaterial should also match, for example, a MaterialVariant with BaseMaterial Grass can only be assigned to MaterialService.GrassName, not AsphaltName or any other names. These properties are not scriptable but can read and write using MaterialService:GetBaseMaterialOverride() and MaterialService:SetBaseMaterialOverride() function.

MaterialService has a MaterialService.Use2022Materials property that switches between legacy materials and new materials introduced in year 2022. Because legacy and user-generated (new) terrain materials use different encoding, using legacy terrain materials and MaterialVariant at the same time has a performance penalty. If your game is using pre-2022 terrain materials, avoid overriding any built-in materials. Migrate to 2022 materials if possible.

Summary

Properties

Specify MaterialVariant name to override built-in Asphalt.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Basalt.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Brick.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Cobblestone.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Concrete.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in CorrodedMetal.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in CrackedLava.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in DiamondPlate.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Fabric.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Foil.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Glacier.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Granite.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Grass.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Ground.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Ice.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in LeafyGrass.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Limestone.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Marble.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Metal.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Mud.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Pavement.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Pebble.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Plastic.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Rock.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Salt.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Sand.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Sandstone.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Slate.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in SmoothPlastic.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in Snow.

NOT SCRIPTABLE

Switch built-in material pack.

NOT REPLICATED

Specify MaterialVariant name to override built-in Wood.

NOT SCRIPTABLE

Specify MaterialVariant name to override built-in WoodPlanks.

NOT SCRIPTABLE

Events

Methods


Get the override MaterialVariant name of specified Material type.


Get the effective MaterialVariant reference given a name and Material.


Set a MaterialVariant name that overrides a built-in material.

Properties

AsphaltName

Not Scriptable

Specify MaterialVariant name to override built-in Asphalt. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Asphalt.

BasaltName

Not Scriptable

Specify MaterialVariant name to override built-in Basalt. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Basalt.

BrickName

Not Scriptable

Specify MaterialVariant name to override built-in Brick. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Brick.

CobblestoneName

Not Scriptable

Specify MaterialVariant name to override built-in Cobblestone. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Cobblestone.

ConcreteName

Not Scriptable

Specify MaterialVariant name to override built-in Concrete. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Concrete.

CorrodedMetalName

Not Scriptable

Specify MaterialVariant name to override built-in CorrodedMetal. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to CorrodedMetal.

CrackedLavaName

Not Scriptable

Specify MaterialVariant name to override built-in CrackedLava. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to CrackedLava.

DiamondPlateName

Not Scriptable

Specify MaterialVariant name to override built-in DiamondPlate. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to DiamondPlate.

FabricName

Not Scriptable

Specify MaterialVariant name to override built-in Fabric. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Fabric.

FoilName

Not Scriptable

Specify MaterialVariant name to override built-in Foil. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Foil.

GlacierName

Not Scriptable

Specify MaterialVariant name to override built-in Glacier. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Glacier.

GraniteName

Not Scriptable

Specify MaterialVariant name to override built-in Granite. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Granite.

GrassName

Not Scriptable

Specify MaterialVariant name to override built-in Grass. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Grass.

GroundName

Not Scriptable

Specify MaterialVariant name to override built-in Ground. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Ground.

IceName

Not Scriptable

Specify MaterialVariant name to override built-in Ice. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Ice.

LeafyGrassName

Not Scriptable

Specify MaterialVariant name to override built-in LeafyGrass. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to LeafyGrass.

LimestoneName

Not Scriptable

Specify MaterialVariant name to override built-in Limestone. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Limestone.

MarbleName

Not Scriptable

Specify MaterialVariant name to override built-in Marble. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Marble.

MetalName

Not Scriptable

Specify MaterialVariant name to override built-in Metal. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Metal.

MudName

Not Scriptable

Specify MaterialVariant name to override built-in Mud. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Mud.

PavementName

Not Scriptable

Specify MaterialVariant name to override built-in Pavement. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Pavement.

PebbleName

Not Scriptable

Specify MaterialVariant name to override built-in Pebble. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Pebble.

PlasticName

Not Scriptable

Specify MaterialVariant name to override built-in Plastic. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Plastic.

RockName

Not Scriptable

Specify MaterialVariant name to override built-in Rock. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Rock.

SaltName

Not Scriptable

Specify MaterialVariant name to override built-in Salt. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Salt.

SandName

Not Scriptable

Specify MaterialVariant name to override built-in Sand. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Sand.

SandstoneName

Not Scriptable

Specify MaterialVariant name to override built-in Sandstone. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Sandstone.

SlateName

Not Scriptable

Specify MaterialVariant name to override built-in Slate. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Slate.

SmoothPlasticName

Not Scriptable

Specify MaterialVariant name to override built-in SmoothPlastic. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to SmoothPlastic.

SnowName

Not Scriptable

Specify MaterialVariant name to override built-in Snow. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Snow.

Use2022Materials

Not Replicated

When it's false, built-in materials use the material pack before 2022. When it's true, built-in materials use the material pack released in 2022.

WoodName

Not Scriptable

Specify MaterialVariant name to override built-in Wood. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to Wood.

WoodPlanksName

Not Scriptable

Specify MaterialVariant name to override built-in WoodPlanks. The Specified MaterialVariant must have MaterialVariant.BaseMaterial set to WoodPlanks.

Events

OverrideStatusChanged

Roblox Script Security

Parameters

material: Material

Methods

GetBaseMaterialOverride

Get the override MaterialVariant name of specified Material type.

Parameters

material: Material

Material type to be fetched.


Returns

MaterialVariant name currently set as override.

GetMaterialOverrideChanged

Roblox Script Security

Parameters

material: Material

GetMaterialVariant

Get the effective MaterialVariant reference given a MaterialVariant name and BaseMaterial. This MaterialVariant must be a descendant of MaterialService. Returns nil if no matching instance exists.

Parameters

material: Material

BaseMaterial of MaterialVariant.

name: string

Name of MaterialVariant.


Returns

A MaterialVariant instance that matches parameters.

GetOverrideStatus

Roblox Script Security

Parameters

material: Material

SetBaseMaterialOverride

Set a MaterialVariant name that overrides a built-in material.

Parameters

material: Material

The Material type to be changed.

name: string

Name of the MaterialVariant object.


Returns