OnCondition
CacheTable:OnCondition(conditionFunction, trueFunction)
Can be called from the Server or Client.
This function will create a call trueFunction when the conditionFunction returns true.
OnCondition Arguments:
conditionFunction | A function that needs to return true or false
trueFunction | The function that is called when conditionFunction returns true
Example Usage for trueFunction:
local GameStatsCache = Cache:Create("GameStats",
{Global = true Replicate = true},
{
GameFinished = false
}
)
InventoryCache:OnCondition(function() return GameStatsCache.Storage.GameFinished end,
function
print("Starting new game")
end)
Example Usage for Wait():
local GameStatsCache = Cache:Create("GameStats",
{Global = true Replicate = true},
{
GameFinished = false
}
)
InventoryCache:OnCondition(function() return GameStatsCache.Storage.GameFinished end):Wait()
print("Starting new game")
Updated almost 2 years ago
Did this page help you?