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