Limiter -- Smart FPS & Connection Manager Utility

:globe_with_meridians: Limiter β€” Smart FPS & Connection Manager Utility

:gear: A simple yet powerful utility to control RunService event frequency and manage connections efficiently.

:open_book: Overview

Limiter is a lightweight utility module designed to help developers control how frequently code runs on fast frame events (like RunService.Heartbeat) and manage connection lifecycles cleanly.

It allows you to:

  • Cap how often your logic executes (e.g., run at 60 FPS instead of 200 FPS).
  • Group and easily clear or destroy multiple connections.
  • Automatically disconnect after a set duration.
  • Keep your performance stable across different FPS environments.

:brain: Why Use Limiter?

By default, RunService.Heartbeat or RenderStepped can fire hundreds of times per second on high-FPS clients.
If your game logic doesn’t need to run that frequently, you’re wasting CPU time and creating potential lag.

Limiter solves that by:

  • Throttling callback execution to a defined FPS.
  • Automatically cleaning up connections in organized groups.
  • Giving you full control and structure over connection management.

:light_bulb: Usage Example

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Limiter = require(ReplicatedStorage.Limiter)

-- Create a Limiter instance
local limiter = Limiter.new()

-- Example: Limit Heartbeat to 60 FPS for 10 seconds
limiter:limit(
    RunService.Heartbeat,          -- RunService event to limit
    function(deltaTime)
        print("Running")
    end,
    60,                            -- FPS cap (use Limiter.Presets if preferred)
    10,                            -- Auto-disconnect after 10 seconds (optional)
    "testing",                     -- Group name for easy management (optional)
    function()
        print("Ended")             -- Called when connection is finished (optional)
    end
)

-- Clear only the "testing" group
limiter:clear("testing")

-- Clear all groups
limiter:clear()

-- Destroy the Limiter instance completely
limiter:destroy()

:toolbox: Core Functions

Function Description
Limiter.new() Creates a new limiter instance.
limiter:limit(signal, callback, fps, duration?, group?, onEnded?) Limits a RunService signal to a custom FPS rate.
limiter:add(connection, group?) Adds a custom connection to be managed by the limiter.
limiter:clear(group?) Clears all or specific group connections.
limiter:getConnections(group?) Returns all connections in a group.
limiter:destroy() Fully destroys the limiter instance and cleans memory.

:memo: Extra Notes

  • :warning: Works with all RunService events: Heartbeat, RenderStepped, Stepped, etc.
  • :puzzle_piece: Each limiter instance can have multiple groups of connections.
  • :collision: Ideal for AI systems, physics updates, visual effects, and background logic that doesn’t need full FPS precision.
  • :broom: Reduces script clutter by organizing and cleaning up signals easily.

:abacus: Example Comparison

FPS Without Limiter With Limiter (60 FPS)
240 ~240 executions/sec 60 executions/sec
120 ~120 executions/sec 60 executions/sec
60 ~60 executions/sec 60 executions/sec

:package: Installation

Roblox Creator Store

https://create.roblox.com/store/asset/109967772174196/Limiter

Model Download

Limiter.rbxm (5.2 KB)

10 Likes