Add `RunService:IsLocalServer()`

Currently there is no way to distinguish between a Local Server test and studio test mode. Having a way to distinguish between these two modes would be useful for testing games that have a different single-player experience to a multiplayer experience.

Having this function would remove the need to having to alter scripts manually everytime you want to test in a different environment as you could just build in support and not have to worry about it past that point.

2 Likes

Your game should be checking if there’s a single player or multiple players loaded in the game. Why do you need a studio-specific property for this?

Is #game.Players:GetPlayers() > 0 not sufficient for you?

Create a local plugin that checks if game.Name == "Server" then set an attribute on Workspace or something that your scripts can read. Plugins load instantly, so you don’t need to instantiate any of the plugin button stuff.

Helps in the meanwhile if this is a pain point during development.

In some cases this isn’t a solution (such as for testing cross server teleports). When teleporting players to a sub-place in your game you probably also want to send the expected player count so you can wait for everyone to connect, and currently the only way to replicate this behaviour in studio is to manually set the expected player count before you local test or to have an arbitrary wait that delays getting the player count (neither of which are ideal).

This is a decent solution, thank you.

2 Likes

You can check the game.JobId. It won’t have one if the server isn’t live

image

Then you can just abstract it into a reusable function

This isn’t relevant, this only distinguishes between studio and a live session not between studio solo play and local server. You can use RunService:IsStudio() to achieve the same thing you have here.

If it’s a local server then the JobId will be nil. I tested that with 2 clients unless I missed what the post was asking for.

This is the button I pressed:
image

Check if the JobId is nil and if its the server, then you have IsLocalServer

1 Like