SpawnManager: Handles player respawn and loading

Purpose

The SpawnManager module is designed to handle player character management in Roblox games. It facilitates tracking of loading times, managing respawn locations, and validating the presence of specific game objects.

Usage

  1. Creating an Instance
    local manager = SpawnManager.new(showElapsedTime, respawnInfo, checkObjectInstance)

Parameters:

  • showElapsedTime (boolean): If true, prints the time taken for each player to load their character. Default: false.
  • respawnInfo (table): Contains respawn information. Example: { RespawnLocation = Vector3.new(10, 20, 30) }. If not used, provide an empty table {}. Default: {}.
  • checkObjectInstance (Instance): The instance to check for presence in the game. If not provided, this check is skipped. Default: nil.

Example:
local manager = SpawnManager.new(true, { RespawnLocation = Vector3.new(10, 20, 30) }, workspace.SomePart)

Starting the Manager
manager:start()

Purpose: Initializes player management, handles character loading, and respawn based on provided parameters.

Features

  • Loading Time Tracking: Optionally tracks and prints the time taken for players to load their characters.
  • Respawn Management: Automatically positions players at specified respawn locations or a default position if not specified.
  • Object Check: Verifies the presence of a specified object in the game before loading characters.

Default Behavior

  • If respawnInfo is not provided or is an empty table, players will be respawned at position (0, 10, 0).
  • If checkObjectInstance is not specified, the object check will be skipped.

Potential Issues

  • Loading Time Print: If showElapsedTime is true, the module will print loading times for every player, which may clutter the output.
  • Respawn Location: Ensure respawnInfo is correctly set up. If the respawn location is not defined, players will be respawned at the default position.
  • Object Check: Verify that checkObjectInstance exists and is correctly referenced in the game to avoid issues with character loading.

With Respawn Location and Object Check:

local manager = SpawnManager.new(true, { RespawnLocation = Vector3.new(50, 10, 50) }, workspace.SomeObject)
manager:start()

Without Respawn Location and Object Check:

local manager = SpawnManager.new(false)
manager:start()

Module: https://create.roblox.com/store/asset/124589316655733/SpawnManager

SpawnManagerModule.rbxl (92,1,KB)

2 Likes

Sorry to bump this post, but how did you make it so that when they teleport after they die it doesn’t spawn them at a checkpoint then teleport the point, is it because it’s teleporting on the server?