Reference API Roblox

Engine API

Website

Related

Reference API Roblox

StudioDeviceSimulatorService

Service allowing you to control Studio's Device Simulator.

This class is not replicated. Its interface does not cross the network boundary.
This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service, NotReplicated]

Member index 17

HistoryMember
717CreateDeviceAsync(config: Dictionary): string
717GetDeviceAsync(): string
717GetDeviceInfoAsync(deviceId: string): Dictionary
717GetDeviceListAsync(): Array
717GetOrientationAsync(): ScreenOrientation
717GetPixelDensityAsync(): float
717GetResolutionAsync(): Vector2
717GetScalingModeAsync(): DeviceSimulatorScalingMode
717RemoveDeviceAsync(deviceId: string): null
717SetDeviceAsync(deviceId: string): null
717SetOrientationAsync(orientation: ScreenOrientation): null
717SetPixelDensityAsync(density: float): null
717SetResolutionAsync(width: int, height: int): null
717SetScalingModeAsync(mode: DeviceSimulatorScalingMode): null
717StopSimulationAsync(): null
717UpdateDeviceAsync(deviceId: string, config: Dictionary): null
717ConfigurationChanged()
inherited from Instance
553Archivable: bool
670Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
702PredictionMode: PredictionMode
670Sandboxed: bool
680UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Description

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.

History 18

Members 17

ConfigurationChanged

Parameters (0)
No parameters.

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.

History 1

CreateDeviceAsync

Parameters (1)
configDictionary
Returns (1)
string

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.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetDeviceAsync

Parameters (0)
No parameters.
Returns (1)
string

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

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetDeviceInfoAsync

Parameters (1)
deviceIdstring
Returns (1)
Dictionary

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:

FieldTypeCreate/UpdateDescription
DeviceIdstringRead-onlyUnique identifier assigned by the service.
NamestringRequiredDisplay name. 1 to 200 characters. Cannot be "default".
WidthnumberRequiredScreen width in pixels. Range: 1 to 7680.
HeightnumberRequiredScreen height in pixels. Range: 1 to 4320.
PixelDensitynumberRequiredPixel density in DPI. Range: 72 to 10000.
DeviceFormDeviceFormOptional (default: Phone)One of Phone, Tablet, Desktop, Console, VR.
IsCustombooleanRead-onlytrue if the device was user-created.
ResolutionScalenumberOptional (default: 1.0)Resolution scaling factor. Must be greater than 0, max 10.0.
PortraitKeyboardHeightnumberOptional (default: 0)Virtual keyboard height in portrait mode.
LandscapeKeyboardHeightnumberOptional (default: 0)Virtual keyboard height in landscape mode.
This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetDeviceListAsync

Parameters (0)
No parameters.
Returns (1)
Array

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

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetOrientationAsync

Parameters (0)
No parameters.
Returns (1)
ScreenOrientation

Returns the current simulated orientation.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetPixelDensityAsync

Parameters (0)
No parameters.
Returns (1)
float

Returns the current simulated pixel density.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetResolutionAsync

Parameters (0)
No parameters.
Returns (1)
Vector2

Returns the current simulated resolution.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

GetScalingModeAsync

Parameters (0)
No parameters.
Returns (1)
DeviceSimulatorScalingMode

Returns the current scaling mode.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

RemoveDeviceAsync

Parameters (1)
deviceIdstring
Returns (1)
null

Removes a custom device.

Errors if the target is a built-in preset.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

SetDeviceAsync

Parameters (1)
deviceIdstring
Returns (1)
null

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.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

SetOrientationAsync

Parameters (1)
orientationScreenOrientation
Returns (1)
null

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

Errors in PlayServer mode.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

SetPixelDensityAsync

Parameters (1)
densityfloat
Returns (1)
null

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.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

SetResolutionAsync

Parameters (2)
widthint
heightint
Returns (1)
null

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.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

SetScalingModeAsync

Parameters (1)
modeDeviceSimulatorScalingMode
Returns (1)
null

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.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

StopSimulationAsync

Parameters (0)
No parameters.
Returns (1)
null

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

Errors in PlayServer mode.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

UpdateDeviceAsync

Parameters (2)
deviceIdstring
configDictionary
Returns (1)
null

Updates a custom device's configuration.

Errors if the target is a built-in preset.

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

Settings