Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I detect if a game is running in studio (build-mode)?

Does anyone know a way to detect if a place is running in build mode, rather than in a Roblox server?

The following would work, but only if HttpEnabled is true.

local z,p = pcall(function() Game:GetService('HttpService'):GetAsync('http://api.roblox.com/') end)
if not z and p == 'Http requests can only be executed by game server' then
	-- Run Build mode specific code here.
end

If HttpEnabled is false p would always be 'Http requests are not enabled' whether the game is in build mode or Roblox Server.

7 comments

0

Why do you need to? The only person that can run it in build mode is you.

0

It is for stopping a certain script from running in build-mode.

0

Just disable the script in Studio when you are about to build on Build Mode. No need for a script to disable it.

0

I am mainly asking if this is possible, of course I could do that though.

0

HTTPService is now allowed in build/edit mode.

0

At that time, it was not.

0

Build mode is destroyed :P

7 answers

The best way is to check the game.PlaceId and game.CreatorId, and if either is 0, then you know it's not a real server. This is NOT a fullproof method, though.

3 comments

0

In build mode, both game.PlaceId and game.CreatorId are as they would be in a game server.

0

Then there is no way.

0

What are you using Build mode for, though? Isn't that thing like...Obsolete?

Per the DataModel documentation game.JobId is "A unique identifier for the current game server. Defaults to the empty string in offline mode".

local offlineMode = game.JobId == ""

By the time I saw this, this question is unanswered for 5 years. Unfortunately, build mode went extinct. Luckily there is a better way that detects if a game is running in studio mode.

local runs = game:GetService("RunService")

if runs:IsStudio() then
	print("it is") --this part does what it needs in studio mode
else
	print("it is not") --this part does what it needs in player mode
end

There is a simple way to detect if they are in studio or not. When in studio, game.Name has the name of the actual file itself.

if game.Name~="Game" then
--Offline specific code here
end

The easiest way is to check if you are in the studio is to see if game.CreatorId equals 0. The reason why you should not check whether game.PlaceId equals 0 is because once you upload your place, ROBLOX assigns a PlaceId to it wich does not equal to 0.

local creatorId = game.CreatorId

if creatorId == 0 then
	print("Currently building in ROBLOX Studio")
end

1 comment

0

doesn't work I printed the creator id and it was mine in build mode

Made by me

StudioMode = nil

if game.Name:sub(string.len(game.Name) - 3, string.len(game.Name)) == "rbxl" then
	StudioMode = true
else
	StudioMode = false
end
print(StudioMode)

This is what I used and it seems to work(I used the PlayerAdded function to aquire the player)

if player.CharacterAppearanceId == player.UserId then
		--Insert non-Build mode script
	else
		--Insert Build mode script
end

This discussion is preserved as it was. New answers, comments, and votes are closed.