As a Roblox developer, it’s currently too hard to detect what identity a script has. As of now, there are two methods:
-
Attempt an action known to require a certain identity and use
pcall
to detect if it worked or not. This will break if the action attempted has its security level changed (which has happened on multiple occasions). -
Use a combination of
printidentity
andLogService
to get the actual script identity, print it to the output, and then parse the new message in the output for the identity. This is convoluted, messy, and can be easily broken if another script prints out a similar message at the same time.
There should definitely be a proper function to get the current script identity. printidentity
could just be changed to, in addition to its current functionality, return the script’s identity as an int. Or an entirely new getidentity function could be created. Either way, a proper method should definitely exist.
My use case is a module that allows for the creation of special objects, but can also modify the selection behavior of the objects when it’s running in a PluginSecurity identity. Currently I’m having to resort to one of these two bad methods to determine if it can run the selection modification component.