Skip to content

Service · inherits Instance

StudioDeviceSimulatorService

Official docs ↗

Service allowing you to control Studio's Device Simulator.

About StudioDeviceSimulatorService

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

  • CreateDeviceAsync(config: Dictionary) → stringYieldsPluginCreates a custom device preset and returns its ID.

    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.

  • GetDeviceAsync() → stringYieldsPluginReturns the ID of the currently active device, or "default" if none is active.

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

  • GetDeviceInfoAsync(deviceId: string) → DictionaryYieldsPluginReturns the configuration dictionary for the specified device.

    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:

  • GetDeviceListAsync() → ArrayYieldsPluginReturns an array of all available device IDs.

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

  • GetOrientationAsync() → ScreenOrientationYieldsPluginReturns the current simulated screen orientation.

    Returns the current simulated orientation.

  • GetPixelDensityAsync() → floatYieldsPluginReturns the current simulated pixel density in DPI.

    Returns the current simulated pixel density.

  • GetResolutionAsync() → Vector2YieldsPluginReturns the current simulated viewport resolution.

    Returns the current simulated resolution.

  • GetScalingModeAsync() → DeviceSimulatorScalingModeYieldsPluginReturns how the simulated resolution currently maps to the Studio viewport.

    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) → ()YieldsPluginRemoves a custom device from the catalog.

    Removes a custom device.

    Errors if the target is a built-in preset.

  • SetDeviceAsync(deviceId: string) → ()YieldsPluginActivates the specified device or stops simulation if "default" is passed.

    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.

  • SetOrientationAsync(orientation: ScreenOrientation) → ()YieldsPluginSets the simulated screen orientation.

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

    Errors in PlayServer mode.

  • SetPixelDensityAsync(density: float) → ()YieldsPluginOverrides the simulated pixel density in DPI for the current session.

    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.

  • SetResolutionAsync(width: int, height: int) → ()YieldsPluginOverrides the simulated viewport resolution for the current session.

    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.

  • SetScalingModeAsync(mode: DeviceSimulatorScalingMode) → ()YieldsPluginSets how the simulated resolution maps to the Studio viewport.

    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.

  • StopSimulationAsync() → ()YieldsPluginStops the active device simulation.

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

    Errors in PlayServer mode.

  • UpdateDeviceAsync(deviceId: string, config: Dictionary) → ()YieldsPluginUpdates the configuration of an existing custom device.

    Updates a custom device's configuration.

    Errors if the target is a built-in preset.

Events 1

  • ConfigurationChangedStudioDeviceSimulatorService.ConfigurationChanged:Connect(function())PluginFires when the active simulation state changes.

    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.

StudioDeviceSimulatorService also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.