Zone Speed Gate Module

A pure Luau helper that evaluates a current Speed value against a zone requirement and returns access, gap, and progress data.

Roblox Studio ModuleScript

What this script does

Keep zone eligibility math separate from doors, UI, teleports, and saved player data.

Best for
Original biome, trail, training, and route gates in a Studio project.
Language
Luau
Version
1.0.0
Validation
Luau runtime tested
Luau runtime tested

Official Luau 0.735 parsing and strict analysis pass, and the module is covered by the pure-module runtime behavior harness.

Included behavior

  • Allowed-state and remaining gap
  • Normalized progress value
  • No character or door side effects

Install in the stated runtime

  1. 1
    Create a ModuleScript named ZoneGate.
  2. 2
    Paste the complete source and require it from a server or test Script in your own experience.
  3. 3
    Supply a trusted server-side Speed value and let your own server decide what an allowed result unlocks.

Minimal usage example

local ZoneGate = require(script.Parent.ZoneGate)
local result = ZoneGate.evaluate(7_500, 10_000)
print(result.allowed, result.gap, result.progress)

Example inputs and result

Supply
Current Speed and the requirement for a zone in your own game.
Expect
evaluate returns access, remaining gap, and progress fields.

These notes explain the example above. Read the complete source for every exported function and edge case before integrating it.

Complete source

No hidden import, minified block, or shortened loader.

--!strict
-- MIT License. Pure zone-requirement math; it does not move or modify players.

local ZoneGate = {}

function ZoneGate.evaluate(currentSpeed: number, requiredSpeed: number)
	assert(currentSpeed >= 0 and requiredSpeed >= 0, "Speed values must be non-negative")
	local gap = math.max(0, requiredSpeed - currentSpeed)
	local progress = if requiredSpeed == 0 then 1 else math.clamp(currentSpeed / requiredSpeed, 0, 1)
	return { allowed = gap == 0, gap = gap, progress = progress }
end

function ZoneGate.firstReachable(currentSpeed: number, requirements: { number }): number?
	for index, requirement in requirements do
		if currentSpeed >= requirement then return index end
	end
	return nil
end

return table.freeze(ZoneGate)
SHA-2568de1e88733611278e5a0d8fc96aa65ea3aaf40dfd96eb84d874ff204ec51e01e

Outside this script’s scope

  • Bypass a live zone requirement
  • Read Steal An Egg Speed

Found a problem or a better approach?

Tell us what failed, what you expected, and whether the issue happened in the Luau CLI or Roblox Studio. Suggestions for clearer types, safer server checks, or a more useful API are welcome.

Do not submit credentials, private project files, or account data.