Configs
This API is used to retrieve the values of Gamebeast configs.
local Gamebeast = require(game:GetService("ReplicatedStorage"):WaitForChild("Gamebeast"))
local GamebeastConfigs = Gamebeast:GetService("Configs")Shared Methods
These methods are used to retrieve and listen to the values of configs that are shared across all players & servers in the experience. When a per-player experiment is active, these methods will only return the config revelant to the run context (server or client). To retrieve player-specific configs on the server, use the Server Methods below.
:Get(path)
{[string] : any} | anyreturn type
This function is used to retrieve the value of a specific config. It can accept either a single
string or a list of strings as the path parameter. The :Get method will yield until the configs
are loaded from Gamebeast.
pathstring | {string}The configuration path to retrieve. You can provide either a single string or a list of strings.
Usage
-- string
local SunPosition = GamebeastConfigs:Get("SunPosition")
-- Path (array of strings)
local SunPosition = GamebeastConfigs:Get({"SunPosition"})
local Health = GamebeastConfigs:Get({"NPCs", "Spider", "Health"}):OnChanged(path, callback)
RBXScriptSignalreturn type
This function is used to listen to the value a specific config changing. It can accept either a
single string or a list of strings as the path parameter.
pathstring | {string}The configuration path to retrieve. You can provide either a single string or a list of strings.
callback(newValue : any, oldValue : any) -> ()Callback function fired when the config on the provided path changes.
Usage
-- string
GamebeastConfigs:OnChanged("SunPosition", function(newValue, oldValue)
print("New config", newValue)
end)
-- Path (array of strings)
local ChangedConnection = GamebeastConfigs:OnChanged({"Lighting", "Atmosphere"}, function(newValue, oldValue)
print("New config", newValue)
end):Observe(path, callback)
RBXScriptSignalreturn type
Similar to :OnChanged, this function fires the provided callback when the target config either changed, or becomes available after being initially fetched from Gamebeast.
pathstring | {string}The configuration path to retrieve. You can provide either a single string or a list of strings.
callback(newValue : any, oldValue : any) -> ()Callback function fired when the config on the provided path is ready, or is changed.
Usage
-- string
GamebeastConfigs:Observe("SunPosition", function(newValue, oldValue)
-- Old value will be nil if the config was not previously available
print("Config is ready/changed", newValue)
end)
-- Path (array of strings)
local ObserveConnection = GamebeastConfigs:Observe({"Lighting", "Atmosphere"}, function(newValue, oldValue)
print("Config is ready/changed", newValue)
end):IsReady()
booleanreturn type
Returns a boolean indicating whether the config are loaded and ready to be used.
Usage
if GamebeastConfigs:IsReady() then
print("Configs are ready!")
end:OnReady(callback)
RBXScriptSignalreturn type
This method fires a callback once the configs are loaded from Gamebeast.
callback(configs : any) -> ()Callback function fired when the configs are ready.
Usage
GamebeastConfigs:OnReady(function(configs)
print("Configs are ready!", configs)
end)Server Methods
These methods are primarily useful for configs that are per-player when experiments are active. They allow you to retrieve and listen to player-specific configurations.
:GetForPlayer(player, path)
{[string] : any} | anyreturn type
This function is used to retrieve the value of a specific config for a specific player. It can
accept either a single string or a list of strings as the path parameter. This method will yield
until the configs are loaded from Gamebeast.
playerPlayerThe player to retrieve the config for.
pathstring | {string}The configuration path to retrieve. You can provide either a single string or a list of strings.
Usage
game:GetService("Players").PlayerAdded:Connect(function(player : Player)
if GamebeastConfigs:IsReady() == false then
print("Configs are not ready yet, :GetForPlayer will yield until they are ready.")
end
-- string
local SunPosition = GamebeastConfigs:GetForPlayer(player, "SunPosition")
-- Path (array of strings)
local SunPosition = GamebeastConfigs:GetForPlayer(player, {"SunPosition"})
local Health = GamebeastConfigs:GetForPlayer(player, {"NPCs", "Spider", "Health"})
end):OnChangedForPlayer(player, path, callback)
RBXScriptSignalreturn type
This function is used to listen to the value a specific player's config is changing. It can accept
either a single string or a list of strings as the path parameter.
playerPlayerThe player whose config we're listening to.
pathstring | {string}The configuration path to retrieve. You can provide either a single string or a list of strings.
callback(newValue : any, oldValue : any) -> ()Callback function fired when the config on the provided path changes.
Usage
game:GetService("Players").PlayerAdded:Connect(function(player : Player)
-- string
GamebeastConfigs:OnChangedForPlayer(player, "SunPosition", function(newValue, oldValue)
print("New config", newValue)
end)
-- Path (array of strings)
local ChangedConnection = GamebeastConfigs:OnChangedForPlayer(player, {"Lighting", "Atmosphere"}, function(newValue, oldValue)
print("New config", newValue)
end)
end):ObserveForPlayer(player, path, callback)
RBXScriptSignalreturn type
Similar to :OnChanged, this function fires the provided callback when the player's target config either changed, or becomes available after being initially fetched from Gamebeast.
playerPlayerThe player whose config we're observing.
pathstring | {string}The configuration path to retrieve. You can provide either a single string or a list of strings.
callback(newValue : any, oldValue : any) -> ()Callback function fired when the config on the provided path is ready, or is changed.
Usage
game:GetService("Players").PlayerAdded:Connect(function(player : Player)
-- string
GamebeastConfigs:ObserveForPlayer("SunPosition", function(newValue, oldValue)
-- Old value will be nil if the config was not previously available
print("Config is ready/changed", newValue)
end)
-- Path (array of strings)
local ObserveConnection = GamebeastConfigs:ObserveForPlayer({"Lighting", "Atmosphere"}, function(newValue, oldValue)
print("Config is ready/changed", newValue)
end)
end)