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.
1 | local z,p = pcall ( function () Game:GetService( 'HttpService' ):GetAsync( 'http://api.roblox.com/' ) end ) |
2 | if not z and p = = 'Http requests can only be executed by game server' then |
3 | -- Run Build mode specific code here. |
4 | end |
If HttpEnabled is false p would always be 'Http requests are not enabled' whether the game is in build mode or Roblox Server.
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.
Per the DataModel documentation game.JobId is "A unique identifier for the current game server. Defaults to the empty string in offline mode".
1 | 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.
1 | local runs = game:GetService( "RunService" ) |
2 |
3 | if runs:IsStudio() then |
4 | print ( "it is" ) --this part does what it needs in studio mode |
5 | else |
6 | print ( "it is not" ) --this part does what it needs in player mode |
7 | 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.
1 | if game.Name~ = "Game" then |
2 | --Offline specific code here |
3 | 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.
1 | local creatorId = game.CreatorId |
2 |
3 | if creatorId = = 0 then |
4 | print ( "Currently building in ROBLOX Studio" ) |
5 | end |
Made by me
1 | StudioMode = nil |
2 |
3 | if game.Name:sub(string.len(game.Name) - 3 , string.len(game.Name)) = = "rbxl" then |
4 | StudioMode = true |
5 | else |
6 | StudioMode = false |
7 | end |
8 | print (StudioMode) |
This is what I used and it seems to work(I used the PlayerAdded function to aquire the player)
1 | if player.CharacterAppearanceId = = player.UserId then |
2 | --Insert non-Build mode script |
3 | else |
4 | --Insert Build mode script |
5 | end |