the art of detection

by shy · · updated

~13 minute read


this article is focused on Roblox scripting and internals

if you're my friend, you probably know about my Roblox game flex your operating system

now, if you're familiar with Roblox's scripting, you probably know that scripts have permission levels. if you don't know, scripts have a permission system depending on where they are running from and who wrote them. you may be aware of this if you have ever exploited on Roblox, as many executors advertise their level ("Level 3", "Level 7", "Level 8" are the common ones you'll see)

typically, LocalScripts, Scripts, and ModuleScripts have a permission level of 3. but when Roblox writes scripts for the client itself, those are called CoreScripts, which have a permission level of 5. this obviously gives them access to functions Roblox uses for the CoreGuis and LuaApp

you may wonder, why is this relevant? the security context required for UserInputService:GetPlatform(), which returns the operating system the user is running on, is locked behind RobloxScript. this means that a game like fyos shouldn't be possible, yet i've done it. how?

backstory

okay well before i can answer that, i want to give a little backstory for fyos

when i first created fyos, i kinda had no idea what i was doing. i hadn't written Lua in a while at all, and i had only recently been able to play Roblox again thanks to Sober

naturally, the idea came up in the context of banning all Windows users from a game. interestingly enough, Roblox actually provides a way to check if the user is running Windows, in the form of GuiService.IsWindows. this is obviously old and deprecated, but it did (and still does) work

so after having a bit of fun with that, i thought "what if i made a game about flexing your operating system?", because that's what Linux users love doing...

so now let me get onto the main point, what black magic is behind this?

detection

the answer is fairly simple, yet complex: find a ton of microscopic differences between the individual game clients, or what Roblox allows us to access outside of the vm, to detect the operating system

in theory, this sounds kinda easy, but in practice, it's actually pretty hard

client types

the first step to os detection is figuring out what kind of client you're on. Roblox has three clients: desktop, mobile and console. they all have mild differences, which is helpful in ultimately detecting the operating system

when Sober released, the first thing i noticed was that the chat menu said "To chat click here or press Slash key" instead of "To chat click here or press / key". this is because desktop/console clients and mobile clients do keycodes differently, and this was my first client detector

this is actually pretty reliable still, but i recently discovered that the UWP client (the Microsoft Store version which is for some reason a mobile client) returns the desktop keycodes instead. this leads me to believe it depends on the os you're running rather than the client type, but this is irrelevant for now

even though this was already reliable, i sought out a more logical way of detecting the client type. that is when i came across version(), which returns the Roblox client's version

the following clients return the following version formats:
desktop: 0.major.revision.all
mobile: 2.major.?
console: 1.major.revision.?

so this gave me a way to differentiate between client types 100% reliably, although for console i continue to use GuiService:IsTenFootInterface() because Roblox says it's 100% guaranteed

so now that i could detect mobile clients, i had to face the problem of differentiating between iOS and Android

iOS vs Android

originally, the breakthrough i had was by checking the width of U+FFFD. this sounds very unrelated at first, but i noticed that on iOS it was consistently 12.5

i now know that this is related to DPI, and within days, this method had already been found to be flawed

i felt hopeless after this because i spent days trying to find SOMETHING that was different, until i realized it: U+F8FF

if you're somewhat knowledgable about Unicode, you probably already know where this is going. U+F8FF is a codepoint in the Private Use Area range, and is notably set to the Apple logo on Apple's operating systems

this was the breakthrough i was looking for, and i wrote this function:

local TextService = game:GetService('TextService')
local invalidCharSize = TextService:GetTextSize(utf8.char(65535), 16, 'SourceSans', Vector2.one * 1000) --u+ffff (explicitly invalid character)

function hasCharacter(codepoint)
    local charSize = TextService:GetTextSize(utf8.char(codepoint), 16, 'SourceSans', Vector2.one * 1000)
    local charExists = (invalidCharSize.Magnitude ~= charSize.Magnitude)
    if charExists then
        return true
    else
        return false
    end
end

it compares the size of U+F8FF to the size of U+FFFF, which is an invalid character. the idea is that if both are the same size, then both are invalid, but if they aren't then one exists. obviously, it'll be the one you want to check for because U+FFFF will always be invalid

using this method, i can now differentiate between iOS and Android consistently

so, what about Sober?

as you may know, Sober is a runtime for the Android client to run on a Linux desktop. but obviously, if i'm making a game for Linux users, i can't just call them Android users

the naive approach to detecting Sober is by just checking if it's Android with a mouse and keyboard. this is actually what i did in the early days, until i accidentally discovered a method to detect Sober specifically

when i transitioned to using version() for differentiating between clients, i noticed that it broke that Sober detection. i realized that version() returned an empty string on Sober, because the developers forgot to call nativeSetRobloxVersion in the emulated JNI (Java Native Interface)

this was my golden method, i was unironically very proud of it. it lasted for a while, until someone in the VinegarHQ server posted a Sober help thread titled "Game able to see I'm on Linux, even though Sober uses Android"

the Sober developers found the fact that i detected Sober very funny, and someone asked me how exactly it works. i told them about the method i discovered, assuming it was intentional for some reason, and it was soon patched

it was almost patched in the way i hoped for, which was by returning the desktop client version instead of the mobile client version, meaning i could detect it by checking for mobile keycodes on a desktop client. when the lead developer of Sober patched it in this way, they noticed that it caused my detection to pivot to macOS

after a bit of conversation about how it worked, they changed their mind, meaning that Sober would report the actual version and not the desktop client equivalent. this absolutely sucked, since i hadn't found another way to detect Sober specifically

i did have a fallback method though, it was something i had noticed when differentiating between iOS and Android: desktop clients always seemed to return a width of 13 for U+FFFD

this is the method i relied on for the longest, i couldn't find a flaw but i never understood why it worked. eventually, i figured it out: DPI. i mentioned this earlier, but this was actually when i found that out. setting the enable_hidpi option to true in Sober's config could break this detection, so i stopped relying on it

luckily, i had actually found another method by this point, which i then used for a few months. it checked if FFlagUserHandleChatHotKeyWithContextActionService was enabled, which is a fast flag that fixes opening legacy chat with the slash key. Sober was the only client that specifically set this flag, and kept it even after Roblox removed it since forked legacy chats could still benefit from it

then, i found out that Sober not reporting a touchscreen is actually a Sober-specific thing, meaning that isMobileClient and not hasTouch is actually a viable method of detecting Sober (when i thought it was the cheap way...)

this is because the Android client's engine HARDCODES TouchEnabled, for some ungodly reason. this is part of the reason why chromeOS Roblox is so unbearable. Sober fixes this through black magic, meaning it should be the only Android client without touch, aside from the Quest client which also doesn't report touch

the only flaw in this detection method is that you can enable touch in the Sober config, but no sane user would do that even if they had a touchscreen because it would confuse/break many games

this is the method i use now, since it's the most explicit. the flag behind the fast flag method will likely be removed from Sober soon anyways, since legacy chat is going to be removed

the obvious stuff

now that the cool stuff is out of the way, i'm gonna sorta rapidfire through the obvious stuff

consoles

you can officially differentiate between consoles by checking the keycodes for their buttons. i particularly use Enum.KeyCode.ButtonL2 for this, where on Xbox it's equal to ButtonLT, and on PlayStation it's equal to ButtonL2

you could check GuiService.IsWindows to detect Xbox vs PlayStation, but i highly doubt this method will ever break because it is intentional

the Meta Quest

the Quest version of Roblox is a mobile client, particularly Android. since it's the only mobile client with VR code, you can just check if it's a mobile client in VR. not very Explicit, but it works and will probably work forever

Windows vs macOS

there are only two desktop clients: WindowsPlayer and MacPlayer. so, if it's a desktop client and it's not GuiService.IsWindows, it's macOS. i don't use the Apple character method for this one because i've observed that it seemingly doesn't see the Apple character on the macOS client

the result

in essence, the script ends up looking like this:

if isConsoleClient then
    if triggerButtonKeyCodeString == 'ButtonLT' then
        osName = 'Xbox'
    elseif triggerButtonKeyCodeString == 'ButtonL2' then
        osName = 'PlayStation'
    end
else
    if isWindows then
        osName = 'Windows'
    elseif isDesktopClient then
        osName = 'macOS'
    elseif isMobileClient and hasVr then
        osName = 'Meta Horizon OS'
    elseif isMobileClient and hasAppleChar then
        osName = 'iOS'
    elseif isMobileClient and not hasTouch then
        osName = 'Linux' --(sober)
    elseif isMobileClient then
        osName = 'Android'
    end
end

this is Actually the script powering fyos, minus the variable definitions and such

analytics

this isn't exactly related to detection, but while we're here, i would like to show you the fyos os analytics (updated march 1st 2026)

1. Windows: 2,782 users
2. iOS: 1,092 users
3. Android: 950 users
4. Linux: 756 users
5. macOS: 298 users
6. PlayStation: 295 users
7. Xbox: 262 users
8. Meta Horizon OS: 86 users

i find it Very funny that Linux users are so high up, because it's only due to the fact that they(including me, arch btw) stereotypically love flexing their operating system. in a normal game, i would honestly expect it to be last

conclusion

to be honest, fyos wasn't the only thing i wanted to talk about in this post. but, the other thing i'm working on that involves detection is currently classified. if/when i reveal it, i still likely won't be able to make a post on it for a long time, as revealing it's internals would be detrimental

now that you have all of this information, i humbly request you do Not steal my game... but you can use all of this knowledge for whatever you want


↵go home