3. Prompt Engineering
d. Adding Features

Adding Features to Existing Systems

When you want to expand an existing Roblox system with new functionality, proper communication with SuperbulletAI is essential to ensure seamless integration. Here's your guide to successfully adding features without breaking existing code.

1. Understand Your Existing System First

Document Current Functionality

Before requesting new features, clearly understand what you already have:

System Overview:

  • What does the current system do?
  • How do players interact with it?
  • What data does it store/manage?
  • What other systems does it connect to?

Technical Details:

  • Key scripts and their locations
  • RemoteEvents and RemoteFunctions used
  • Data structures and storage methods
  • Performance characteristics

Example System Documentation

Current System: Player Inventory
- Stores items in ReplicatedStorage.PlayerData
- Uses RemoteEvent "UpdateInventory" for client-server sync
- Maximum 20 items per player
- Items have: Name, Quantity, Rarity, Icon
- Connected to: Shop system, Trading system
- Located in: ServerScriptService.InventoryManager

2. Feature Request Best Practices

Provide Complete Context

Always start with context about the existing system:

I have an existing player inventory system that stores items in ReplicatedStorage.PlayerData
with Name, Quantity, Rarity, and Icon properties. It uses RemoteEvent "UpdateInventory"
for sync and supports 20 items maximum.

Add a new feature: Item categories (Weapons, Tools, Consumables) with filtering UI.

Specify Integration Requirements

Be explicit about how the new feature should work with existing code:

Add item categories to my existing inventory system:

EXISTING: Items have Name, Quantity, Rarity, Icon
NEW: Add Category property ("Weapons", "Tools", "Consumables")

REQUIREMENTS:
- Don't break existing item data structure
- Use current UpdateInventory RemoteEvent
- Add filtering buttons to existing UI
- Maintain 20-item limit per category

3. Effective Feature Addition Prompts

Template for Feature Requests

FEATURE ADDITION REQUEST:

Existing System: [Brief description of current functionality]

Current Architecture: [Key technical details]

New Feature: [What you want to add]

Integration Requirements:
- [How it should work with existing code]
- [Data compatibility needs]
- [UI/UX considerations]

Constraints:
- [Performance requirements]
- [Compatibility requirements]
- [Security considerations]

Success Criteria: [How to know it works correctly]

Real Example

FEATURE ADDITION REQUEST:

Existing System: Combat system with basic sword fighting, health management,
and respawn functionality

Current Architecture:
- Health stored in player.Character.Humanoid.Health
- Damage dealt via RemoteEvent "DealDamage"
- Weapons are Tool objects in StarterPack
- Respawn at fixed spawn points

New Feature: Weapon durability system where weapons degrade with use

Integration Requirements:
- Add Durability attribute to existing weapon Tools
- Use current DealDamage RemoteEvent to track usage
- Show durability in existing weapon UI
- Weapons break and disappear when durability reaches 0

Constraints:
- Must work with all existing weapons
- No performance impact during combat
- Compatible with current weapon trading system

Success Criteria: Weapons lose durability with each hit, display current
durability, and properly remove when broken

4. Maintaining System Compatibility

Backwards Compatibility

Always specify that existing functionality must continue working:

Add team-based respawning to my current respawn system.

CRITICAL: Existing single-player respawn must continue working unchanged
for players not on teams.

Data Migration

When adding new data fields, address existing data:

Add "XP" and "Level" fields to my player data system.

For existing players without these fields:
- Set XP = 0
- Set Level = 1
- Update the data structure automatically on login

Version Compatibility

Add new spell casting to my magic system, but make it optional so servers
can enable/disable it via a configuration setting in ServerStorage.

5. UI and UX Integration

Extending Existing Interfaces

When adding UI features, specify how they should integrate:

Add a "Sort by Rarity" button to my existing inventory GUI.

EXISTING UI: Grid layout with item frames, search bar at top
NEW: Add sort dropdown next to search bar
- Options: "Name", "Rarity", "Quantity"
- Use same styling as existing buttons
- Remember player's sort preference

Maintaining User Experience

Add item tooltips to my shop system.

REQUIREMENTS:
- Show on hover, just like existing weapon inspect tooltips
- Use same tooltip style from inventory system
- Include: Item name, description, price, stats
- Don't interfere with click-to-purchase functionality

6. Performance Considerations

Scaling Existing Systems

Add guild functionality to my player data system.

PERFORMANCE REQUIREMENTS:
- Support up to 100 guild members
- Don't slow down existing player data loading
- Use efficient data structure for guild lookups
- Minimal impact on server memory usage

Optimization Requests

Add real-time leaderboard updates to my current scoring system.

CONSTRAINTS:
- Update maximum every 5 seconds to prevent lag
- Use existing score calculation logic
- Only show top 10 players to limit UI overhead

7. Security and Validation

Extending Security Models

Add item trading to my inventory system.

SECURITY REQUIREMENTS:
- Use same validation as existing shop purchases
- Prevent item duplication exploits
- Add trade confirmation system
- Log all trades for admin review
- Respect existing anti-cheat measures

Access Control

Add admin commands to my current chat system.

REQUIREMENTS:
- Use existing admin detection (game.Players:GetUserIdFromNameAsync)
- Only work for users in existing AdminList
- Don't interfere with normal chat functionality
- Add permission levels: Moderator, Admin, Owner

8. Testing New Features

Integration Testing

Add the new weather system, then create a test script that verifies:
1. Weather changes don't break existing day/night cycle
2. Rain effects work with current lighting system
3. Weather data saves/loads with existing world data
4. Performance stays above 30 FPS with weather active

Compatibility Testing

Test the new clan system by:
1. Having players join clans, then use existing features (shop, inventory, combat)
2. Verify clan data doesn't interfere with existing player data
3. Check that players can leave/rejoin clans without data loss
4. Ensure clan features work in both single and multiplayer modes

9. Common Integration Pitfalls

Avoid These Mistakes

Vague integration requirements: "Add quests to my game"

Clear integration specification: "Add quest system that integrates with my existing NPC dialogue system and inventory rewards"

Ignoring existing data: "Change player data to include new stats"

Considering migration: "Add new stats to player data with migration for existing players"

Assuming compatibility: "Add multiplayer features"

Specifying compatibility: "Add multiplayer features that work with my existing single-player save system"

10. Feature Rollout Strategies

Gradual Implementation

Implement the crafting system in phases:

Phase 1: Basic item combination (2 items → 1 result)
Phase 2: Add recipe discovery system
Phase 3: Integrate with existing skill progression
Phase 4: Add advanced crafting stations

Test each phase before proceeding to the next.

Feature Flags

Add the new PvP arena system with a configuration toggle:
- ServerStorage.GameConfig.PvPEnabled = true/false
- When false, arena exists but no combat allowed
- Seamlessly enable/disable without server restart
- Respect existing combat system rules when enabled

11. Advanced Integration Techniques

Event System Integration

Add achievement system that hooks into existing game events:
- Listen for existing RemoteEvents (PlayerKill, ItemPurchase, LevelUp)
- Don't modify existing event logic
- Add achievement checks as observers, not modifiers
- Use same event naming conventions as current system

Modular Architecture

Design the new building system as a module that:
- Plugs into existing player data system
- Uses current permission checks for plot ownership
- Integrates with existing material inventory
- Can be disabled without affecting other systems

12. Documentation and Maintenance

Update Documentation

After adding the new feature, update the system documentation to include:
- New data structures and their relationships
- Additional RemoteEvents and their purposes
- Updated system dependencies
- Configuration options for the new feature

Maintenance Prompts

Create maintenance tools for the new auction house feature:
- Admin command to view all active auctions
- Script to clean up expired auctions
- Database integrity check for auction/inventory sync
- Performance monitoring for auction queries

Quick Reference: Feature Addition Template

ADD FEATURE: [Feature name] to [Existing system]

CURRENT SYSTEM:
- Purpose: [What it does now]
- Architecture: [Key technical details]
- Data: [Current data structures]

NEW FEATURE:
- Functionality: [What to add]
- Integration: [How it connects]
- UI: [Interface requirements]

CONSTRAINTS:
- Compatibility: [What must not break]
- Performance: [Requirements and limits]
- Security: [Validation and access control]

TESTING: [How to verify it works]

Example:

ADD FEATURE: Item enchanting to Combat system

CURRENT SYSTEM:
- Purpose: Sword combat with damage calculation
- Architecture: Tools in StarterPack, RemoteEvent "DealDamage"
- Data: Weapon stats stored in Tool attributes

NEW FEATURE:
- Functionality: Add magical enchantments to weapons
- Integration: Extend current damage calculation with enchant bonuses
- UI: Add enchanting interface to existing weapon inspection

CONSTRAINTS:
- Compatibility: All existing weapons must work unchanged
- Performance: No lag during combat calculations
- Security: Server-side enchantment validation

TESTING: Verify enchanted and normal weapons both work in combat

Remember: Successful feature additions enhance existing systems without breaking them. Always consider the bigger picture and how new features affect the overall user experience.