Configs
This API is used to retrieve the values of Gamebeast configs.
For more information about Configurations, visit the Configurations Guide.
local Gamebeast = require(game:GetService("ReplicatedStorage"):WaitForChild("Gamebeast"))
local GamebeastConfigs = Gamebeast:GetService("Configs") :: Gamebeast.ConfigsServicePaths
Every method takes a path to a value. The first segment is the configuration's ID, the short name you copy from its ⋯ menu with Copy ID, such as economy-tuning. The configuration's name also works. The remaining segments walk into the configuration's values.
Pass a list of strings, or a single string to read a whole configuration.
-- The whole configuration
local economy = GamebeastConfigs:Get("economy-tuning")
-- One value inside it
local spiderHealth = GamebeastConfigs:Get({"economy-tuning", "NPCs", "Spider", "Health"})A configuration's ID changes when you rename it, so update your paths when you do.
Updates
Your game gets dashboard changes while it's running. Servers check for changes every 30 seconds by default, and fetch only the configurations that changed. Clients receive just the values that changed from their server.
Change how often servers check with the statusPollRate setting. In Studio it defaults to 5 seconds. Use :OnChanged or :Observe to run your code when a value changes.
Values marked private on the dashboard are never sent to clients.
Shared Methods
These methods read the configuration values for the current run context. On the server they return the server's values; on a client, that player's values. When a player is in a per-player experiment, their client's values already include their group's changes. To read a specific player's values on the server, use the Server Methods below.
Tables returned by these methods are shared with the SDK. Read them, but don't modify them.
:Get(path)
anyreturn type
Returns the value at path, or nil if there is none. Yields until the configurations have loaded
from Gamebeast.
pathstring | {string}The path to the value. See Paths.
Usage
local sunPosition = GamebeastConfigs:Get({"lighting", "SunPosition"})
local spiderHealth = GamebeastConfigs:Get({"economy-tuning", "NPCs", "Spider", "Health"}):OnChanged(path, callback)
RBXScriptConnectionreturn type
Calls callback whenever the value at path changes, or anything inside it if it's a table.
pathstring | {string}The path to the value. See Paths.
callback(newValue : any, oldValue : any) -> ()Called with the new and previous values. Both are read-only.
Usage
local connection = GamebeastConfigs:OnChanged({"lighting", "Atmosphere"}, function(newValue, oldValue)
print("Atmosphere changed", newValue)
end):Observe(path, callback)
RBXScriptConnectionreturn type
Like :OnChanged, but also calls callback once with the current value as soon as the
configurations have loaded.
pathstring | {string}The path to the value. See Paths.
callback(newValue : any, oldValue : any) -> ()Called with the new and previous values. oldValue is nil on the first call.
Usage
GamebeastConfigs:Observe({"lighting", "SunPosition"}, function(newValue, oldValue)
print("Sun position is now", newValue)
end):IsReady()
booleanreturn type
Returns whether the configurations have loaded.
Usage
if GamebeastConfigs:IsReady() then
print("Configs are ready!")
end:OnReady(callback)
RBXScriptConnectionreturn type
Calls callback once the configurations have loaded, or right away if they already have.
callback(configs : {[string] : any}) -> ()Called with every configuration, keyed by ID.
Usage
GamebeastConfigs:OnReady(function(configs)
print("Configs are ready!", configs["economy-tuning"])
end)Server Methods
These methods read a specific player's values. A player's values differ from the server's when they're in a per-player experiment; otherwise they're the same.
:GetForPlayer(player, path)
anyreturn type
Returns the value at path for player, or nil if there is none. Yields until the configurations
have loaded from Gamebeast.
playerPlayerThe player to read the value for.
pathstring | {string}The path to the value. See Paths.
Usage
game:GetService("Players").PlayerAdded:Connect(function(player : Player)
local spiderHealth = GamebeastConfigs:GetForPlayer(player, {"economy-tuning", "NPCs", "Spider", "Health"})
end):OnChangedForPlayer(player, path, callback)
RBXScriptConnectionreturn type
Calls callback whenever the value at path changes for player, including when they join or
leave an experiment group that changes it.
The connection is disconnected automatically shortly after the player leaves.
playerPlayerThe player whose value to listen to.
pathstring | {string}The path to the value. See Paths.
callback(newValue : any, oldValue : any) -> ()Called with the new and previous values. Both are read-only.
Usage
game:GetService("Players").PlayerAdded:Connect(function(player : Player)
local connection = GamebeastConfigs:OnChangedForPlayer(player, {"lighting", "Atmosphere"}, function(newValue, oldValue)
print(player.Name, "atmosphere changed", newValue)
end)
end):ObserveForPlayer(player, path, callback)
RBXScriptConnectionreturn type
Like :OnChangedForPlayer, but also calls callback once with the player's current value as soon
as the configurations have loaded.
The connection is disconnected automatically shortly after the player leaves.
playerPlayerThe player whose value to observe.
pathstring | {string}The path to the value. See Paths.
callback(newValue : any, oldValue : any) -> ()Called with the new and previous values. oldValue is nil on the first call.
Usage
game:GetService("Players").PlayerAdded:Connect(function(player : Player)
GamebeastConfigs:ObserveForPlayer(player, {"lighting", "SunPosition"}, function(newValue, oldValue)
print(player.Name, "sun position is now", newValue)
end)
end)