If I were to make a projectile system, I would emit the bullets on the player’s client. I’d like to know if replicating the bullets CFrame on every frame would be ok. The server would then update the bullet’s CFrame.
I was thinking of a method to fire an event to all clients and just make a new bullet overall, but this would cause some problems. If a player gets hit, they could be seeing the bullet farther away from them.
I haven’t really worked with projectiles but I believe this is a terrible method.
Since 1, you already pointed this out but yeah, the player’s gonna see the bullet a bit farther back. And 2, there’s an easier way of doing “emitting the bullet on player’s client and having server replicate it to all clients,” which is setting the NetworkOwnership of the bullet to the client.
When i’ve made bullets, replicating them each frame was terrible for bandwidth, the best thing you can do is to tell the client to calculate projectile on their computer and tell the server to do the same, if you have client-sided projectiles it’s even easier, because server don’t need to actually re-calculate it
Would not recommend. At worst case, each cframe presumably takes up 12b/vector * 4 vectors = 48b total, plus a type overhead of 1b, plus a remote invocation overhead of 9b, equalling a total of 58b per cframe replicated in the worst case (source). That times 60 frames per second, 3.5kb per second. That times maybe 10 bullets active at once (say, from an automatic weapon) = 35kb per second merely in outgoing data from your gun — now imagine the incoming data when the whole server starts firing their guns!
Instead, consider the following:
On gun fired:
Player fires gun. Handles physics. Tells server that they fired gun.
Server hears that player fired gun. Server tells other players that player fired gun.
Other players make a mock bullet visual and handle the physics for it of their own accord.
On bullet hit:
Player who fired and therefore controls bullet physics tells server that they hit someone.
Server hears of this. Checks positional data to see if that makes sense (the logic for this could be more or less complicated depending on your needs — perhaps you just need to check for a line of sight; perhaps you need to also handle physics on the server and compare hit positions to see if they’re close enough, perhaps something else; either way, my advice is to choose the simplest method that meets your needs).
If everything checks out, register the hit, deal damage, whatever.