Roblox UtilitiesDevlHub Roblox Documentation

Class

StudioDeviceSimulatorService

NotCreatableServiceNotReplicated
Inherits
Instance › Object
Memory category
Instances

Service allowing you to control Studio's Device Simulator.

Provides programmatic control over Studio's Device Simulator. Use this service to switch between device presets, override resolution and pixel density, control orientation and scaling, and manage custom device profiles from a plugin or from an external tool connected through the MCP server.

All methods are asynchronous and yield the calling coroutine. The service is available in Edit mode and Play Client. Methods that modify the active simulation state are blocked in PlayServer mode.

Limitations#
  • All methods are asynchronous and yield the calling coroutine.
  • Methods that modify the active simulation state (SetDeviceAsync, StopSimulationAsync, SetOrientationAsync, SetResolutionAsync, SetPixelDensityAsync, SetScalingModeAsync) error in PlayServer mode. They work in Edit mode and Play Client.
  • UpdateDeviceAsync and RemoveDeviceAsync error when called on built-in presets.
  • Resolution, DPI, and scaling mode methods require an active device and error when GetDeviceAsync() returns "default".
  • Resolution and DPI overrides are session-level. They are not persisted and are cleared on SetDeviceAsync.
  • Built-in presets are immutable.

Methods 16#

CreateDeviceAsyncCreates a custom device preset and returns its ID.PluginSecurity securityYields
GetDeviceAsyncReturns the ID of the currently active device, or "default" if none is active.PluginSecurity securityYields
GetDeviceInfoAsyncReturns the configuration dictionary for the specified device.PluginSecurity securityYields
GetDeviceListAsyncReturns an array of all available device IDs.PluginSecurity securityYields
GetOrientationAsyncReturns the current simulated screen orientation.PluginSecurity securityYields
GetPixelDensityAsyncReturns the current simulated pixel density in DPI.PluginSecurity securityYields
GetResolutionAsyncReturns the current simulated viewport resolution.PluginSecurity securityYields
GetScalingModeAsyncReturns how the simulated resolution currently maps to the Studio viewport.PluginSecurity securityYields
RemoveDeviceAsyncRemoves a custom device from the catalog.PluginSecurity securityYields
SetDeviceAsyncActivates the specified device or stops simulation if "default" is passed.PluginSecurity securityYields
SetOrientationAsyncSets the simulated screen orientation.PluginSecurity securityYields
SetPixelDensityAsyncOverrides the simulated pixel density in DPI for the current session.PluginSecurity securityYields
SetResolutionAsyncOverrides the simulated viewport resolution for the current session.PluginSecurity securityYields
SetScalingModeAsyncSets how the simulated resolution maps to the Studio viewport.PluginSecurity securityYields
StopSimulationAsyncStops the active device simulation.PluginSecurity securityYields
UpdateDeviceAsyncUpdates the configuration of an existing custom device.PluginSecurity securityYields

CreateDeviceAsync(config: Dictionary): string#

YieldsPluginSecurity security

Creates a custom device and returns its newly assigned ID. Custom devices are persisted to disk and appear in the Device Simulator UI.

Errors if any required field is missing or out of range.

NameTypeDefaultDescription
configDictionaryA dictionary describing the new device. Required fields: Name (string, 1-200 characters, cannot be "default"), Width (int, 1-7680 pixels), Height (int, 1-4320 pixels), PixelDensity (int, 72-10000 DPI). Optional fields: DeviceForm (DeviceForm, default Phone), ResolutionScale (float, default 1.0, max 10.0), PortraitKeyboardHeight (int, default 0), LandscapeKeyboardHeight (int, default 0).
Returns
  • string — string

GetDeviceAsync(): string#

YieldsPluginSecurity security

Returns the ID of the currently active device, or "default" if no device is active.

Returns
  • string — string

GetDeviceInfoAsync(deviceId: string): Dictionary#

YieldsPluginSecurity security

Returns a DeviceConfiguration for the specified device without activating it. Useful for inspecting presets before choosing one to switch to.

The returned dictionary contains the following fields:

Field Type Create/Update Description
DeviceId string Read-only Unique identifier assigned by the service.
Name string Required Display name. 1 to 200 characters. Cannot be "default".
Width number Required Screen width in pixels. Range: 1 to 7680.
Height number Required Screen height in pixels. Range: 1 to 4320.
PixelDensity number Required Pixel density in DPI. Range: 72 to 10000.
DeviceForm Enum.DeviceForm Optional (default: Phone) One of Phone, Tablet, Desktop, Console, VR.
IsCustom boolean Read-only true if the device was user-created.
ResolutionScale number Optional (default: 1.0) Resolution scaling factor. Must be greater than 0, max 10.0.
PortraitKeyboardHeight number Optional (default: 0) Virtual keyboard height in portrait mode.
LandscapeKeyboardHeight number Optional (default: 0) Virtual keyboard height in landscape mode.
NameTypeDefaultDescription
deviceIdstringThe unique identifier of the device to query. Must be a valid ID from GetDeviceListAsync(); cannot be "default".
Returns
  • Dictionary — A dictionary containing the device configuration and passed to CreateDeviceAsync and UpdateDeviceAsync.

GetDeviceListAsync(): Array#

YieldsPluginSecurity security

Returns an array of device IDs for all available presets, including built-in and custom devices.

Returns
  • Array — An array of device IDs.

GetOrientationAsync(): ScreenOrientation#

YieldsPluginSecurity security

Returns the current simulated orientation.

Returns

GetPixelDensityAsync(): float#

YieldsPluginSecurity security

Returns the current simulated pixel density.

Returns
  • float — number

GetResolutionAsync(): Vector2#

YieldsPluginSecurity security

Returns the current simulated resolution.

Returns

GetScalingModeAsync(): DeviceSimulatorScalingMode#

YieldsPluginSecurity security

Returns the current DeviceSimulatorScalingMode for how the simulated resolution maps to the Studio viewport. See SetScalingModeAsync() for the available modes.

Requires an active device; errors when GetDeviceAsync() returns "default".

RemoveDeviceAsync(deviceId: string): ()#

YieldsPluginSecurity security

Removes a custom device.

Errors if the target is a built-in preset.

NameTypeDefaultDescription
deviceIdstringThe unique identifier of the custom device to remove.
Returns
  • ()

SetDeviceAsync(deviceId: string): ()#

YieldsPluginSecurity security

Activates the specified device. Passing "default" stops simulation and is equivalent to calling StopSimulationAsync.

Errors in PlayServer mode. Errors if the device ID does not exist.

NameTypeDefaultDescription
deviceIdstringThe unique identifier of the device to activate, or "default" to stop simulation.
Returns
  • ()

SetOrientationAsync(orientation: ScreenOrientation): ()#

YieldsPluginSecurity security

Sets or gets the simulated screen orientation. Accepts Portrait, LandscapeLeft, or LandscapeRight. Other values will error.

Errors in PlayServer mode.

NameTypeDefaultDescription
orientationScreenOrientationThe target screen orientation. Accepted values are ScreenOrientation.Portrait, ScreenOrientation.LandscapeLeft, or ScreenOrientation.LandscapeRight.
Returns
  • ()

SetPixelDensityAsync(density: float): ()#

YieldsPluginSecurity security

Overrides or returns the simulated pixel density in DPI. Session-level; cleared on device switch.

This method requires an active device. SetPixelDensityAsync also errors in PlayServer mode.

NameTypeDefaultDescription
densityfloatThe pixel density override in DPI. Must be between 72 and 10000.
Returns
  • ()

SetResolutionAsync(width: int, height: int): ()#

YieldsPluginSecurity security

Overrides the simulated viewport resolution or returns the current resolution as a Vector2. Overrides are session-level and cleared when you switch devices.

Coordinates are in landscape space: the first parameter maps to the horizontal axis in landscape, the second to the vertical axis. In portrait, axes are swapped automatically.

Both methods require an active device. They error if GetDeviceAsync() returns "default". SetResolutionAsync also errors in PlayServer mode.

NameTypeDefaultDescription
widthintThe viewport width in pixels (horizontal axis in landscape orientation). Range: 1 to 7680.
heightintThe viewport height in pixels (vertical axis in landscape orientation). Range: 1 to 4320.
Returns
  • ()

SetScalingModeAsync(mode: DeviceSimulatorScalingMode): ()#

YieldsPluginSecurity security

Controls how the simulated resolution maps to the Studio viewport.

  • ScaleToPhysicalSize scales the viewport to approximate physical device size.
  • ActualResolution renders at exact pixel resolution.
  • FitToWindow scales to fill the viewport.

Both methods require an active device. SetScalingModeAsync also errors in PlayServer mode.

Returns
  • ()

StopSimulationAsync(): ()#

YieldsPluginSecurity security

Stops the active simulation. Prefer this over SetDeviceAsync("default") for clarity.

Errors in PlayServer mode.

Returns
  • ()

UpdateDeviceAsync(deviceId: string, config: Dictionary): ()#

YieldsPluginSecurity security

Updates a custom device's configuration.

Errors if the target is a built-in preset.

NameTypeDefaultDescription
deviceIdstringThe unique identifier of the custom device to update.
configDictionaryA dictionary of device fields to apply. Uses patch semantics: omitted optional fields retain their current values. Same schema as CreateDeviceAsync().
Returns
  • ()

Events 1#

ConfigurationChangedFires when the active simulation state changes.PluginSecurity security

ConfigurationChanged()#

PluginSecurity security

Fires when the active simulation state changes: device switch, orientation, resolution, pixel density, scaling mode, or user interaction with the Device Simulator UI. Does not fire for catalog-only operations such as CreateDeviceAsync, UpdateDeviceAsync on a non-active device, RemoveDeviceAsync on a non-active device, or GetDeviceInfoAsync.

Getter calls inside the handler are async and will yield.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed