Roblox Skill with Mana, Cooldown, and Server-Side Security
Generate a professional special skill implementation for Roblox, including mana or energy consumption, cooldown, anti-spam protection, and visual feedback for the player. The prompt was structured to produce safe, modular code ready to adapt to your project.
The solution requires a client-server architecture: the client captures the key/button and displays the interface, while the server fully validates resources, cooldown, character state, and skill effects. Ideal for RPGs, combat games, arenas, simulators, and skill-based experiences.
Before generating the code, simply paste the real names of the objects in your Explorer, available RemoteEvents, the structure of mana attributes/values, and details of the desired effect. The result will include complete, commented scripts and practical instructions for testing in Roblox Studio.
Act as a senior Roblox developer, specialized in Luau, client-server architecture, secure combat, and scalable skill systems. Create a complete implementation of a special skill with mana/energy cost and cooldown, ready for me to adapt and paste into Roblox Studio. Before writing the code, use the context below. If any data is missing, do not invent critical object names: declare a short section called "Assumptions adopted" and use default names that are easy to replace. Do not ask follow-up questions; deliver a functional solution with these assumptions. My game context is: - Skill name and effect description: [COLE AQUI] - Key, mobile button, or control action to activate: [COLE AQUI] - Mana/energy cost per use: [COLE AQUI] - Cooldown in seconds: [COLE AQUI] - Where mana/energy is stored (Attribute, NumberValue, leaderstats, folder, etc.): [COLE AQUI] - Maximum value and mana/energy regeneration rules: [COLE AQUI] - RemoteEvents/RemoteFunctions already existing, with their paths in the Explorer: [COLE AQUI] - Existing UI objects (ScreenGui, button, bar, labels), if any: [COLE AQUI] - Skill effect (damage, dash, projectile, healing, area, buff, etc.) and parameters: [COLE AQUI] - Relevant Explorer structure and exact folder/model names: [COLE AQUI] - Extra rules, such as allowed teams, required tool, minimum level, or states that block use: [COLE AQUI] Mandatory implement an architecture with the following files, clearly identifying the TYPE and the location of each one in the Explorer: 1. A configuration ModuleScript in ReplicatedStorage/Shared/AbilityConfig (or equivalent path provided by me), containing cost, cooldown, range, names/IDs, and adjustable skill parameters. 2. A server Script in ServerScriptService, responsible for the authoritative logic. It must safely create or locate the activation RemoteEvent, control cooldown per UserId on the server, validate Player, Character, Humanoid, HumanoidRootPart, life state, resource cost, extra rules, and all arguments sent by the client. The server must deduct mana/energy only after validations and execute the real skill effect. Never trust the client to provide damage, valid target, position, direction, cost, cooldown, currency, inventory, or collision result. 3. A LocalScript in StarterPlayer/StarterPlayerScripts or StarterGui, according to the UI provided, to capture input via ContextActionService or UserInputService, prevent local spam, request activation via RemoteEvent, and update cooldown/mana feedback. The client should handle the visual experience, but not decide the skill result. For skills with target, raycast, or area, final validation must occur on the server. Use Workspace:Raycast with RaycastParams when applicable, limit range and direction based on the real HumanoidRootPart position, and apply damage exclusively with Humanoid:TakeDamage on the server. Add rate limiting in addition to cooldown when it makes sense, protect against removed/respawned characters, disconnect temporary connections, and avoid memory leaks. Do not use loadstring, HttpService, obfuscated code, imprecise waits when task.wait is appropriate, or unnecessary infinite loops. Deliver the response in exactly this organization: first, a quick overview of the architecture and assumptions; then, a section for each file with its path in the Explorer, script type, and complete Luau code. All code must be inside markdown blocks labeled as ```lua, be complete, executable, and extensively commented in Brazilian Portuguese. Do not provide pseudocode, incomplete snippets, or comments like "add your logic here" without a functional standard implementation. Include error handling with warn only when useful, reference validation with WaitForChild using timeout where appropriate, and a clear strategy for mana/energy Attributes or NumberValues. If I do not specify the UI, implement minimal feedback through controlled notifications/prints and leave documented integration points. At the end, include an objective section "How to test in Roblox Studio", explaining the Explorer setup, value configuration, testing with Play and Start Server/Start Player, test scenarios for insufficient mana, cooldown, RemoteEvent spam, death/respawn, and multiplayer validation.