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 9 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.

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.

0
Why do you need to? The only person that can run it in build mode is you. ipiano 120 — 9y
0
It is for stopping a certain script from running in build-mode. Epidemiology 116 — 9y
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 — 9y
0
I am mainly asking if this is possible, of course I could do that though. Epidemiology 116 — 9y
View all comments (3 more)
0
HTTPService is now allowed in build/edit mode. Nickoakz 231 — 8y
0
At that time, it was not. Epidemiology 116 — 8y
0
Build mode is destroyed :P greatneil80 2647 — 6y

7 answers

Log in to vote
1
Answered by 9 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 — 9y
0
Then there is no way. NoahWillCode 370 — 9y
0
What are you using Build mode for, though? Isn't that thing like...Obsolete? NoahWillCode 370 — 9y
Ad
Log in to vote
1
Answered by 7 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".

local offlineMode = game.JobId == ""
Log in to vote
1
Answered by 3 years ago
Edited 3 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.

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
Log in to vote
0
Answered by 8 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.

if game.Name~="Game" then
--Offline specific code here
end
Log in to vote
0
Answered by 7 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.

local creatorId = game.CreatorId

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

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)
Log in to vote
0
Answered by 6 years ago

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

Answer this question