Run, pause and stop the simulation
playtestStarts and stops Roblox Studio playtests with modes for single player, headless, or multiplayer sessions.
Instructions
Starts and stops playtests, so scripts can be made to run and then observed without asking the user to press anything.
play is the Play button: a character spawns and Players.PlayerAdded fires. run is Run mode, which executes scripts with no player at all. multiplayer starts a test with several players for testing replication. state reports without changing anything.
Pressing play adds a SECOND connected session for the playtest's server, and that is where the running game lives — console, performance and execute_luau must target its studioId, not the editor's. Call list_studios after starting and look for the entry whose context is a playtest.
A test does not block this call: it starts and the reply reports the state reached. Studio only ends it when something inside calls StudioTestService:EndTest(value) or when stop is used here; whatever EndTest passed comes back as lastResult on a later state. That makes a scripted check possible end to end: args is readable inside the test via StudioTestService:GetTestArgs(), so a test can be told what to do and report back what happened.
Stopping discards everything the playtest changed, exactly as pressing Stop does. Build in edit mode, then play — not the other way round.
The reply says whether the mode actually moved, not merely that Studio accepted the request.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | Yes | 'play' starts a playtest with a character, 'run' runs scripts with no player, 'multiplayer' starts a several-player test, 'stop' ends it and discards its changes, 'state' only reports. | |
| args | No | Value handed to the test, readable inside it with `StudioTestService:GetTestArgs()`. Use it to tell a test which case to exercise. | |
| players | No | multiplayer only: how many players to start. | |
| studioId | No | Target Studio; omit for the active one. |