When testing a game within Roblox Studio only, the RunService:IsRunMode()
method always returns true
in a server-sided script, regardless of any of the three possible ways to start game from within Roblox Studio; ‘Play’, ‘Play Here’ & ‘Run’.
But according to the API documentation for IsRunMode, only when using the green ´Run´ button, IsRunMode()
should return true
- so shouldn’t it then return false
(also in a server-sided script) when using the ‘Play’ and ‘Play Here’ buttons?
Roblox Studio only enters run mode when the ‘Run’ button is pressed, not the ‘Play’ button.
How to experience this “bug”
Create an empty game, using nothing more than the baseplate template, and then add the following server- and client-scripts:
-- (server) 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())
-- (client) 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())
Then go through starting the game three times, using the ‘Run’, then ‘Play Here’ and last the ‘Play’ button, and notice the results in Output-panel. (Below output’s layout is 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
, and not follow what the description at the API documentation page specifies it should do.