Creating weapons
You cannot have a battle royale game without having weapons. In this section, you will learn how to make a comprehensive and secure gun system that makes use of raycasting
for hit detection.
Figure 6.1: A laser gun model from the Toolbox
To begin making the weapon system, start by adding a new module to the ServerHandler
script, named Weapons
. In this module, we will include the necessary services, variables, and other necessary references. As you can see with the hitRemote
and replicateRemote
variables, we will need two RemoteEvent
instances parented to ReplicatedStorage
, named Hit
and Replicate
respectively. These will be used so that the client and server can communicate with each other when necessary. Implement the following code block into your new module:
local playerService = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local hitRemote = replicatedStorage.Hit
local replicateRemote...