Skip to content

Instantly share code, notes, and snippets.

@MaximumADHD
Last active August 10, 2024 22:39
Show Gist options
  • Save MaximumADHD/1a7e045afc7beb6f472f8e5f684e2aa0 to your computer and use it in GitHub Desktop.
Save MaximumADHD/1a7e045afc7beb6f472f8e5f684e2aa0 to your computer and use it in GitHub Desktop.
RunContext - What's the running context of your code?
--!strict
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
local RunService = game:GetService("RunService")
local VRService = game:GetService("VRService")
local isEdit = false
local isServer = RunService:IsServer()
local isClient = RunService:IsClient()
local isStudio = RunService:IsStudio()
local isOnline = game.JobId ~= ""
local isRCC = isOnline and isServer
pcall(function ()
isEdit = RunService:IsEdit()
end)
return table.freeze({
IsRCC = isRCC,
IsEdit = isEdit,
IsTestRun = isStudio
and not isEdit,
IsServer = isServer,
IsClient = isClient,
IsStudio = isStudio,
IsOnline = isOnline,
IsTenFoot = GuiService:IsTenFootInterface(),
IsTouch = UserInputService.TouchEnabled,
IsVR = VRService.VREnabled,
})
@PhoenixWhitefire
Copy link

8p1( 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment