API Reference
The Security System exposes a set of public methods on SS_SecuritySystem for other Udon scripts to interact with it — whether that's checking a player's roles for a custom door or sign, or granting/revoking roles from your own UI.
Every method takes an explicit VRCPlayerApi player argument — pass Networking.LocalPlayer for checks against yourself.
Read Methods
These are pure reads of already-synced state — safe to call from any client, and they don't require holding any particular role or ownership.
HasRole
Checks whether a player currently holds a role. Two overloads are available:
public bool HasRole(VRCPlayerApi player, int roleIndex)
public bool HasRole(VRCPlayerApi player, string role)
| Parameter | Type | Description |
|---|---|---|
player | VRCPlayerApi | Player to check. |
roleIndex / role | int / string | Role to check, by index or by name. |
Returns false for an out-of-range index or an unknown role name, rather than throwing.
GetRoles
Gets every role a player currently holds.
public string[] GetRoles(VRCPlayerApi player)
Parameters:
| Parameter | Type | Description |
|---|---|---|
player | VRCPlayerApi | Player to check. |
Returns an array of role names in role index order, or an empty array (never null) if the player holds nothing or isn't currently tracked.
GetHighestRole
Gets a player's single most senior role, based on the role hierarchy.
public string GetHighestRole(VRCPlayerApi player)
Parameters:
| Parameter | Type | Description |
|---|---|---|
player | VRCPlayerApi | Player to check. |
"Highest" means most senior in the parent/child chain (the held role with the longest chain of children beneath it), not first/last by list order. Returns "" if the player holds no role.
IsRolePermanent
Checks whether a player holds a role permanently (whitelisted, instance owner, or permanent-via-keypad) rather than as a revocable grant.
public bool IsRolePermanent(VRCPlayerApi player, int roleIndex)
| Parameter | Type | Description |
|---|---|---|
player | VRCPlayerApi | Player to check. |
roleIndex | int | Role to check. |
IsPlayerSecurity
Checks whether a player holds at least one role flagged Is Security.
public bool IsPlayerSecurity(VRCPlayerApi player)
| Parameter | Type | Description |
|---|---|---|
player | VRCPlayerApi | Player to check. |
Write Methods
These mutate synced role state and require the caller's local player to hold a Security role — see Security Permission.
GrantRole
Grants a role to a player as a temporary (revocable) hold, cascading to its required child role if any.
public void GrantRole(VRCPlayerApi player, int roleIndex)
| Parameter | Type | Description |
|---|---|---|
player | VRCPlayerApi | Player to grant the role to. |
roleIndex | int | Role to grant. |
No-ops (logged) if the local caller isn't the object's owner or doesn't hold a Security role.
RevokeRole
Revokes a role from a player, cascading up to every held role that requires it.
public void RevokeRole(VRCPlayerApi player, int roleIndex)
| Parameter | Type | Description |
|---|---|---|
player | VRCPlayerApi | Player to revoke the role from. |
roleIndex | int | Role to revoke. |
If satisfying the cascade would require revoking a permanent role, the whole operation is refused and nothing changes — see Role Hierarchy.
Keypad Methods
KeypadPassword
Matches an entered password to a role and toggles that role for the local player — grants it if not held, or logs them out of it if held temporarily. Called internally by SS_SecurityKeypad; you generally won't need to call this directly unless you're building a custom keypad UI.
public string KeypadPassword(string password)
Returns the matched role's name if its held state actually changed, or "" if there was no match, the role is held permanently, or the logout was refused.
WasLastKeypadActionLogout
Reports whether the most recent KeypadPassword call was a logout rather than a grant, since the return value alone can't distinguish the two.
public bool WasLastKeypadActionLogout()
GetRoleColorByName
Looks up a role's configured color by name.
public Color GetRoleColorByName(string roleName)
Encryption Methods
Used to prepare or verify encrypted whitelist content — see Encryption.
public string EncryptText(string text, string key)
public string DecryptText(string text, string key)
Both are reversible: DecryptText reverses whatever EncryptText produced with the same key. DecryptText returns its input unchanged if it isn't valid, even-length hex, rather than throwing or returning garbage.