How to Make a Battlegrounds Game - Lecture Notes

Jul 16, 2024

How to Make a Battlegrounds Game - Lecture Notes

Introduction

  • Series on making Battlegrounds games continues.
  • Previous episodes covered how to set up parts of the game.
  • This video focuses on reworking and simplifying the system.
  • New setup involves 110 lines of code across four scripts (previously 200 lines).

Initial Game Setup

Spawn Locations

  1. Create Spawn Locations

    • Click 'Model' -> 'Spawn' to create locations.
    • Duplicate to create multiple spawn points (e.g., four).
    • Spread them out in the game world.
  2. Naming and Organizing Spawns

    • Name spawn points appropriately (e.g., 'Location 2', 'Location 3', etc.).

Remote Events

  1. Set up Remote Event

    • Insert a remote event into 'Replicated Storage' and name it 'core event'.
  2. Character Folders

    • Create a 'Characters' folder inside 'Server Storage'.
    • Name the characters (e.g., 'Character 1', 'Character 2', etc.).
    • Inside each character folder, insert 'Skill' folders (e.g., 'Skill 1', 'Skill 2').
  3. Animations and Sounds

    • Insert 'Animation' and 'Sound' objects into each skill folder.
    • Set 'Animation ID' and 'Sound ID' appropriately.
  4. Game Pass Characters

    • Insert a 'Number Value' for Game Pass ID if the character is restricted by a game pass.
    • Insert the ID of the relevant Game Pass.

UI (User Interface) Setup

UI Structure

  1. Create Screen GUI

    • Insert a 'Screen GUI' into 'Starter GUI' and name it 'Character Selector GUI'.
    • Insert a 'Local Script' and name it 'core script (local)'.
    • Insert a 'Text Button' named 'dropdown button'.
  2. UI Layout

    • Set the position, size, and properties for the 'Text Button'.
    • Insert a 'UI Corner' for rounded edges.
    • Insert a 'Frame' named 'dropdown frame' with a 'UI Grid Layout'.
    • Insert 'Text Buttons' for each character inside the frame.
    • Set text properties to match the character names.

Scripting

Local Script

  1. Variables and Services

    • User Input Service and Tween Service.
    • Core Event from Replicated Storage.
    • Local Player and Character Selector GUI.
  2. Functions

    • Opening/Closing Character Menu: Checks transparency and toggles tween animations for the dropdown menu.
    • Selecting Character: Sends the selected character's name to the server via 'Core Event'.
    • Using Skills: Handles keyboard inputs for skill activation. Sends skill number to the server.

Leader Stats Script

  1. Setup Data Stores

    • Enable data stores in 'Game Settings' -> 'Security'.
  2. Player Join Function

    • Create 'leaderstats' folder and value objects (kills, total kills, current character).
    • Load player data from the data store.
  3. Player Leaving Function

    • Save player data to the data store.
    • Use pcall and while loop for error handling.

Server Script

  1. Setup Character Selection

    • Load player's character and handle spawn locations.
    • Set current character value and check for Game Pass ownership if required.
  2. Combat Module Script

    • Create functions for each character's skills.
    • Load animations and play sounds.

Testing

  • Verify that characters load properly, and the UI behaves correctly.
  • Ensure that skills are registered but not performing actions yet (to be covered in future videos).

Conclusion

  • Part one covered basic setup and scripting for a Battlegrounds game.
  • Join Discord for support and further updates.
  • Look forward to part two for further functionality.