TokenBucket → Grant & Reset

Grant & Reset

Add tokens back to a player's bucket as a reward or privilege, replenish all active players at once, or reset an individual bucket to its configured starting value.

Signatures

bucket:Grant(player: Player, amount: number?)
bucket:GrantAll(amount: number?)
bucket:Reset(player: Player?)

Behaviour

MethodDescription
GrantAdds amount tokens to the specified player's bucket. The resulting count is capped at max. If amount is omitted, adds 1.
GrantAllAdds amount tokens to every currently active player's bucket. Useful for a server-wide bonus event. Each player is capped at max individually.
ResetSets the player's token count back to the configured start value (defaults to max). If player is omitted, resets all active players.

Example: VIP reward

local bucket = app.TokenBucket

-- Grant 20 bonus tokens when a player buys VIP
MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, purchased)
    if purchased and assetId == VIP_PASS_ID then
        bucket:Grant(player, 20)
    end
end)

-- Server-wide refill at round start
local function onRoundStart()
    bucket:GrantAll()   -- top everyone up by 1, or pass an amount
end

See also

← TokenBucket  ·  Consume & Check | deduct tokens per request  ·  Configuration | max, refillRate, refillInterval