Best way to structure a gun system?

I have a couple of ways that I can personally think of in terms of structuring a weapon system.

A) Create a separate local script, server script, and remote event for each instance of a gun.
B) Create 1 remote event and 1 server script to manage every gun in the game(Each gun would obviously have a separate local script for it)

Is there a limit to how many times a single remote event can be fired? Meaning can it be overloaded by being fired too quickly.

My overall goal here is performance and not organization.

1 Like

I’ll keep this short and sweet :slight_smile:

  1. B is better because fewer instances are created per player.
  2. There is no known limit (that I’m aware of) to how many times you can fire a remote event.
1 Like

Just to clarify, there is no known limit on a rate limiter for remote events? Rate limiter as in limiting the rate at which the remote event is fired, so like capping it at 10/second

I’ve seen errors like these but I’m not sure if that’s the limit or not.

image

edit: it is the limit actually I just checked the replies of the post

1 Like

The limit being 10 times per second is way too low. Use UnreliableRemoteEvents they’re better because you probably don’t need every event to reach the server (Better performance). Also, I would recommend combining A and B if you’re worried about performance. A Unreliable remote event for each player, 1 server script, and 1 local script.

1 Like

Local Script: When user shoots gun, fire remote event
Remote Event: Pass to server
Script: Manage literally everything:

  1. Get the gun equipped and its associated damage. Ensure the user actually owns this gun and has enough ammo.
  2. Subtract ammo from the weapon.
  3. Fire a raycast from the weapon to the direction of the gun barrel.
  4. Check if the hit is a player/humanoid. Subtract associated damage (from line 1)
1 Like

you want to do this on the client and pass the raycast parameters, maybe same with handling ammo.

Arsenal/Weaponry/ACS create projectiles on the client… and ray cast gun systems like old ER LC used client ray casting.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.