Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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.

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

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

0
Why do you need to? The only person that can run it in build mode is you. ipiano 120 — 10y
0
It is for stopping a certain script from running in build-mode. Epidemiology 116 — 10y
0
Just disable the script in Studio when you are about to build on Build Mode. No need for a script to disable it. SlickPwner 534 — 10y
0
I am mainly asking if this is possible, of course I could do that though. Epidemiology 116 — 10y
View all comments (3 more)
0
HTTPService is now allowed in build/edit mode. Nickoakz 231 — 9y
0
At that time, it was not. Epidemiology 116 — 9y
0
Build mode is destroyed :P greatneil80 2647 — 7y

7 answers

Log in to vote
1
Answered by 10 years ago

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.

0
In build mode, both game.PlaceId and game.CreatorId are as they would be in a game server. Epidemiology 116 — 10y
0
Then there is no way. NoahWillCode 370 — 10y
0
What are you using Build mode for, though? Isn't that thing like...Obsolete? NoahWillCode 370 — 10y
Ad
Log in to vote
1
Answered by 8 years ago

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

1local offlineMode = game.JobId == ""
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

1local runs = game:GetService("RunService")
2 
3if runs:IsStudio() then
4    print("it is") --this part does what it needs in studio mode
5else
6    print("it is not") --this part does what it needs in player mode
7end
Log in to vote
0
Answered by 9 years ago

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.

1if game.Name~="Game" then
2--Offline specific code here
3end
Log in to vote
0
Answered by 8 years ago

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.

1local creatorId = game.CreatorId
2 
3if creatorId == 0 then
4    print("Currently building in ROBLOX Studio")
5end
0
doesn't work I printed the creator id and it was mine in build mode KingStared 3 — 8y
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Made by me

1StudioMode = nil
2 
3if game.Name:sub(string.len(game.Name) - 3, string.len(game.Name)) == "rbxl" then
4    StudioMode = true
5else
6    StudioMode = false
7end
8print(StudioMode)
Log in to vote
0
Answered by 7 years ago

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

1if player.CharacterAppearanceId == player.UserId then
2        --Insert non-Build mode script
3    else
4        --Insert Build mode script
5end

Answer this question