RoChartdocs
Feature flags

Flags in your code

Read flags for a player on the game server, record exposures for experiments, and read flags from websites and backends.

Every flag gives your code one of these values:

ValueMeaning
true / falseBoolean flag: on or off for this player.
"control", "test", …Multivariate flag or experiment: the variant.
nil (undefined in JavaScript)Unknown flag, the flag is off, or RoChart couldn't be reached. Take the default path.

In your game (Luau)

Flags are read on the server, for one player:

local variant = RoChart.getFlag(player, "short-tutorial")

if variant == "short" then
  runTutorial(player, SHORT_STEPS)
else
  runTutorial(player, FULL_STEPS) -- "control", false or nil
end
FunctionReturnsCounts as exposure
getFlag(player, key)The valueYes
isFeatureEnabled(player, key)true for on or any variantYes

Targeting uses what RoChart knows about the player: the properties the module sets on join (platform, Premium, country, account age…), your own from setUserProperties, and cohorts.

Because the value is decided on the server, a player can't switch their own variant from the client. If the server needs to tell the client which variant to show, send it with a RemoteEvent or an attribute on the player.

Exposures and experiments

Reading a flag with getFlag or isFeatureEnabled records that the player saw it (a $feature_flag_called event). Experiments only count players who were exposed. So:

  • Read the flag where the experience starts, such as when the tutorial begins or the shop opens, not when the player joins. Otherwise players who never reached the change dilute the result.
  • Handle every variant and nil. Show control when in doubt.
  • The same player keeps their variant on every server, so rejoining or switching devices doesn't reshuffle them.

Websites and backends

The browser and Node SDKs read the same flags, for example on your game's website or in a Discord bot.

const variant = rochart.getFeatureFlag('new-landing-page')
if (variant === 'test') renderNewLanding()

Flags load when the page starts, and again after identify, group and reset. On a first visit they're undefined for a moment; rochart.onFeatureFlags(callback) runs once they're in. Pass { sendEvent: false } to read a flag without recording an exposure, and use rochart.overrideFeatureFlags({ 'new-landing-page': 'test' }) to force values in your own browser while testing (false clears them).

Other languages

POST /i/flags returns every flag for a player. See the SDK reference. If you use a value in an experiment, also send a $feature_flag_called event so the exposure counts.

On this page