Safe Advanced Movement: Double Jump, Dash, and Sprint
This prompt generates an advanced movement system for Roblox with double jump, directional dash, and sprint, designed to work consistently on keyboard, gamepad, and mobile devices. The result prioritizes responsiveness on the client without giving up server authority and validation.
Ideal for obby, action, PvP, RPG, arena, and platform experiences that need modern, configurable controls. The prompt guides the AI to adapt the code to the real structure of your Explorer, to the existing RemoteEvents, and to the specific settings of your project.
The requested solution includes a LocalScript for command capture and local feedback, plus a server Script that creates or uses a RemoteEvent, applies cooldowns, limits spam, and prevents the client from directly setting speed, impulse, or critical character states.
Act as a senior Roblox Luau developer, specialized in secure, responsive, production-ready multiplayer character systems. Generate a complete advanced movement system with double jump, dash, and sprint, adapted to the context of my game below. Before writing the code, consider this project context. If any field is empty, use the safe default values indicated and briefly mention the assumption without stopping the delivery to ask questions: - Name of the existing RemoteEvent (or leave blank to create one): [COLE_AQUI] - Location of RemoteEvents in the Explorer: [COLE_AQUI, ex.: ReplicatedStorage.Remotes] - Is there a custom stamina system? Describe API/attributes/remotes: [COLE_AQUI] - Normal WalkSpeed and desired sprint WalkSpeed: [COLE_AQUI] - Desired dash strength/duration, cooldown, and maximum number of double jumps: [COLE_AQUI] - Desired keys, gamepad buttons, and mobile behavior: [COLE_AQUI] - Does the game have dash/sprint animations? Provide AnimationIds or leave blank: [COLE_AQUI] - Additional restrictions, such as blocking movement while stunned, carrying an item, in a cutscene, or using tools: [COLE_AQUI] - Real names of relevant objects, folders, attributes, modules, or conventions in the Explorer: [COLE_AQUI] Deliver a solution that must consist of EXACTLY TWO complete, self-contained Luau files, directly pasteable into Roblox Studio: 1. A LocalScript called `AdvancedMovementClient`, to be placed in `StarterPlayer > StarterCharacterScripts`. It must capture player intentions using `ContextActionService` and/or `UserInputService`, supporting keyboard, gamepad, and touch buttons created via ContextActionService. The client must request sprint, dash, and double jump actions from the server, but must never set `WalkSpeed`, currency, damage, inventory, final dash force, or permissions on its own. It may control only safe local feedback, such as input states, local animations when appropriate, and cleanup of connections on respawn. 2. A Script called `AdvancedMovementServer`, to be placed in `ServerScriptService`. It must locate the RemoteEvent provided in the context or safely create a `RemoteEvent` called `AdvancedMovementRequest` inside the configured folder in `ReplicatedStorage` if it does not exist. This Script is the source of truth for sprint, dash, and double jump. It must create per-player/per-character state tables, clear data on `PlayerRemoving`, `CharacterAdded`, death, and respawn, and avoid memory leaks or duplicated connections. Implement the following behaviors: sprint while the button is held down, returning immediately to normal speed on release; responsive horizontal dash in the current movement direction, or forward if the player is stationary; double jump allowed only while the character is in the air and still has charges available. The double-jump counter must reset only when the player truly touches the ground. The dash needs server cooldown, must avoid stacking impulse/velocity, ignore dead or seated characters, characters without `HumanoidRootPart`, or invalid states, and preserve stable physics on ramps and falls. Security is mandatory: treat all data coming from the RemoteEvent as untrusted. Validate `player`, current character, `Humanoid`, `HumanoidRootPart`, health, action type, call frequency, cooldown, ground/air state, vector direction, and numeric values. Do not accept velocity, force, cooldown, jump count, or duration values from the client. The dash direction must be calculated or strictly validated on the server from replicated character data, with limited magnitude. Add per-action rate limiting to mitigate spam/exploits. Do not use `loadstring`, remote `require`, infinite uncontrolled loops, or deprecated APIs such as `BodyVelocity`; prefer `ApplyImpulse`, `AssemblyLinearVelocity` with controlled preservation, or modern alternatives justified in code comments. Organize configurable constants at the top of the server Script: normal/sprint speed, dash force, optional duration, cooldown, double-jump vertical impulse, double-jump limit, ground tolerance, rate limits, and remote names. If stamina exists in the provided context, integrate it defensively; otherwise, do not invent external dependencies. Preserve compatibility with Roblox's default controls and camera system. Do not indiscriminately overwrite properties from other systems: store and restore speeds carefully, respecting attributes or locks described in the context. Required response format: start with a short list of where each file should be inserted in the Explorer and which objects will be created automatically. Then deliver the TWO complete code files, each in its own markdown block with the `lua` identifier, with no pseudocode, omitted sections, or comments like “complete here.” Comment the code in Portuguese, explaining validations, cooldowns, state cleanup, and networking decisions. After the code, provide numbered steps to test in Roblox Studio, including Play Solo, Start Server with multiple Players, keyboard/gamepad/touch testing, and a RemoteEvent spam check in Server Output. Finish with a short quick-tuning section indicating exactly which constants to change to balance sprint, dash, and double jump.