Hi all! I am new to the dev forum and game development in general! I am building a voxel mining simulator as my first game, but I’m having trouble finding resources to help me understand the best structure to manage multiplayer mining. Below is a description of how I have set things up so far and the 2 questions I have. I can post my scripts as well if this is not clear enough. Any feedback or comments on this would be very much appreciated.
Mining System Structure:
Client script parented to the mining tool uses UserInputService and ray casting to identify the part a user is hovering their mouse over. If the target part is in range and the user holds mouse button 1, a remote event is fired to the server. The remote event passes the tool’s stats, stored as NumberValues, and the tool’s target block.
A single server side script that I put in ServerScriptService listens to the remote event and runs a while loop that damages the target block after a wait is complete. The damage and wait time is based on 1. the tool stats received and 2. NumberValues parented to all minable blocks that represent total health and base mining speed.
My Questions Are:
Is this client/server structure the best way to manage damage dealing systems to non-humanoids in a game? Sometimes when there are 2 players trying to mine blocks at the same time, the mining functions don’t run. I am trying to figure out if this is because of the structure of my client/server scripts or if I just need to improve the code itself. Can a single server side script be run multiple times instantaneously by different players?
Is storing the health value of a block as a NumberValue parented to every single minable block a bad idea? I structured it this way because I want any client to be able to read a block’s health value and show a gui with that value. But would a table be better? When I try copy a few hundred of these mining blocks, my computer starts to chug very hard (even with an i7 and 2070 gpu).