SpeedSensor (1-Way)
Overview
The SpeedSensor (1-Way) is an automatic trackside sensor for the Railux 6 Ultra train system.
It enforces a speed limit and sets the ATO (Automatic Train Operation) target speed for trains passing over it in one direction.
Features
Sets maximum allowed speed (
SpeedLimit) and ATO target speed (TargetSpeed) for trains.Prevents rapid re-triggering with a configurable debounce timer.
Can be set to transparent in-game for visual simplicity.
Script Reference
local SpeedLimit = 100 -- Maximum allowed speed shown on the speedometer (in SPS).
local TargetSpeed = 100 -- Target speed the train aims for when ATO is active (in SPS).
local DebounceTime = 15 -- Delay time to prevent repeated actions (in seconds)
local TransparentInGame = false -- Whether to set the sensor to transparent or not in-game.
-- DO NOT EDIT UNLESS YOU KNOW WHAT YOU ARE DOING
script.Parent.DirectionGuide:Destroy()
local Debounce = false
if TransparentInGame == true then
script.Parent.Transparency = 1
end
script.Parent.Touched:Connect(function(child)
if child.Name == "TrainTouchSensor" and Debounce == false then
Debounce = true
child.Parent.Parent.Parent.API.Propulsion.SpeedLimit.Value = SpeedLimit
child.Parent.Parent.Parent.API.Propulsion.TargetSpeed.Value = TargetSpeed
task.wait(DebounceTime)
Debounce = false
end
end)Configuration
SpeedLimit
Number
Maximum speed (studs per second, SPS) enforced by the sensor, which is then shown to the driver. (if present)
TargetSpeed
Number
ATO target speed (SPS) the train aims for after passing the sensor.
DebounceTime
Number
Cooldown time (seconds) before the sensor can trigger again.
TransparentInGame
Boolean
If true, hides the sensor part in-game (sets Transparency = 1).
How It Works
Initialization:
The sensor destroys its attached
DirectionGuidepart, if present.Sets itself invisible in-game if
TransparentInGameis true.
Operation:
When a part named
"TrainTouchSensor"touches the sensor and debounce is not active:Sets the train’s speed properties via the API:
API.Propulsion.SpeedLimit.Value = SpeedLimitAPI.Propulsion.TargetSpeed.Value = TargetSpeed
Activates debounce for
DebounceTimeseconds.
Usage Guide
Install the sensor part on your track where a speed limit or ATO target speed change is needed.
Set parameters (
SpeedLimit,TargetSpeed, etc.) at the top of the script.Ensure trains have a part named
"TrainTouchSensor"in their model for compatibility.Adjust
DebounceTimeto prevent multiple triggers from a single train pass (especially for longer trains).
Example
To set a speed limit of -80 SPS and a target ATO speed of -70 SPS, edit the top of the script:
local SpeedLimit = -80
local TargetSpeed = -70
local DebounceTime = 15
local TransparentInGame = trueBest Practices
Place sensors before areas where speed change is needed (e.g., curves, stations).
Use
TransparentInGameto hide sensors during normal gameplay.Test with your train’s
"TrainTouchSensor"to ensure proper activation.
Last updated