RunService:IsRunMode() always returns 'true', even when using 'Play Here'/'Play' in Roblox Studio?

I am trying to detect in a server-sided script, and only when executing the game from within Roblox Studio, if the developer pressed the green ‘Run’ button in Roblox Studio.

However it seems that RunService:IsRunMode() for a server-sided script returns true, even when using the ‘Play Here’ and ‘Play’ buttons in Roblox Studio.

Is the API documentation for IsRunMode wrong? … Or perhaps not specific enough? … Or could this possibly be a real bug for the ‘Studio Bugs’ sub-forum?

I have done some tests, using nothing more than the baseplate template, and the following server- and client-scripts:

-- Script - placed in ServerScriptService
local RunService = game:GetService("RunService")
print("(S)IsStudio =", RunService:IsStudio())
print("(S)IsRunMode=", RunService:IsRunMode()) 
print("(S)IsServer =", RunService:IsServer())
print("(S)IsClient =", RunService:IsClient())
print("(S)IsRunning=", RunService:IsRunning())

-- LocalScript - placed in StarterPlayer/StarterCharacterScripts
local RunService = game:GetService("RunService")
print("(C)IsStudio =", RunService:IsStudio())
print("(C)IsRunMode=", RunService:IsRunMode()) 
print("(C)IsServer =", RunService:IsServer())
print("(C)IsClient =", RunService:IsClient())
print("(C)IsRunning=", RunService:IsRunning())

Using the ‘Run’, ‘Play Here’ and ‘Play’ buttons, results in this output (layout set to be easier to read):

Run
  (S)IsStudio = true
  (S)IsRunMode= true
  (S)IsServer = true
  (S)IsClient = false
  (S)IsRunning= true

Play Here
  (S)IsStudio = true    (C)IsStudio = true
  (S)IsRunMode= true    (C)IsRunMode= false
  (S)IsServer = true    (C)IsServer = false
  (S)IsClient = false   (C)IsClient = true
  (S)IsRunning= true    (C)IsRunning= true

Play
  (S)IsStudio = true    (C)IsStudio = true
  (S)IsRunMode= true    (C)IsRunMode= false
  (S)IsServer = true    (C)IsServer = false
  (S)IsClient = false   (C)IsClient = true
  (S)IsRunning= true    (C)IsRunning= true

As can be seen, the server-sided script’s call to RunService:IsRunMode() always return true - basically making the IsRunMode() useless, and not follow what the description at the API documentation page specifies it should do.

Or is there some weird logic, that can explain why it is doing that?

Are there any work-around for this? Perhaps count the number of players when IsStudio=true & IsServer=true, and if that count is zero then “perhaps” it may have been the ‘Run’ button that was pressed in Roblox Studio?

2 Likes

I was curious and tested this out by joining my game using Roblox Player and running print(game:GetService("RunService"):IsRunMode()) in the console:

It didn’t return true for me. I’ll try it in Studio’s console while in Play mode:

image

Still nothing, but I’ll try it using a server script in the ServerScriptService this time:

image

Gotcha.

I think this is a Studio bug, as it’s explicitly stated the documentation for RunService:IsRunMode() that

Roblox Studio only enters run mode when the ‘Run’ button is pressed, not the ‘Play’ button.

1 Like

Yeah, this is most likely a bug. I think the reason this occurs is because the server is simulated in studio as “run” mode, while the client’s run mode is just disabled.

If you want too, you can file a bug report in #platform-feedback:studio-bugs.

1 Like