This project implements a running system for Roblox games, where players consume stamina when running. The system is split into two scripts:
- Location: Place in
ServerScriptService. - Purpose:
- Sets up a
leaderstatsfolder with aStaminavalue for each player. - Listens for run requests from clients via a
RemoteEvent. - Tracks if each player is running and only regenerates stamina when the player is not running.
- Decreases stamina when the player runs and notifies the client of stamina changes.
- Sets up a
- Location: Place in
StarterPlayerScriptsorStarterCharacterScriptsas aLocalScript. - Purpose:
- Listens for player input (Shift key) to start running.
- Notifies the server when the player starts and stops running.
- Sends run requests to the server while running.
- Updates the player's walk speed based on stamina.
- Receives stamina updates from the server and disables running when stamina is depleted.
- When the player holds Shift, the client notifies the server that running has started and repeatedly requests to run.
- The server checks and decreases stamina, then informs the client.
- If stamina reaches zero, running is disabled until stamina is restored (regeneration only happens when not running).
- When the player releases Shift, the client notifies the server that running has stopped, and stamina begins to regenerate.
- Both scripts (
RunSystemServer.luauandRunSystemClient.luau) have no syntax errors as of the latest check. - If you do find an error, Direct Message @MaxiExecuted on Discord.
- The system can be extended with UI feedback, anti-exploit checks, or custom stamina regeneration rates.
- Always split the code into two scripts as described above for proper Roblox operation.
- The System kind of.. jams?? If you keep running until you no longer can, twice, you'll be softlocked and you can't run anymore.