I have a bullet object and right now i just have it create when you click in a local script.
But i dont want it to be only local side i want other players to be able to see it.
This is my bullet script as it is in the local script
I’m going to say it… Use remote events. If you create the bullet on the server then it shouldn’t lag (If it still does then you might want to not rely on the physics engine to much). If you let the client spawn the bullets, then it is very easily exploitable.
Are you saying to simulate the physics on every client? if so, every player could have a different vision of where the projectile is. it will be very messy
Did you test it in multiplayer? For example, if a player peeks around a wall and shoots, and walks back behind the wall very quickly, by the time the other players are given the signal to simulate that bullet, it will spawn in the wrong position.
Nvm, misunderstood what you meant.
No, the physics details are provided by the server, but the projectile creation and handling of those physics is done by the client.
Many gun kits follow this kind of system.
Client shoots projectile from gun which in turn fires the server → server performs all of the necessary calculations and fires every client → each client creates the projectile and uses the information provided by the server to animate the projectile.
Here’s my thought process on how to go about doing this.
You need a reliable and accurate bullet simulation.
You don’t want it to be exploitable, so you can’t completely trust the client.
Can’t simply fire to server and simulate from there as it looks laggy, has input delay, etc.
What I suggest doing is this:
When firing a bullet, simulate its trajectory on every client separately. To do this, you will need to fire the bullet on the client as well as fire to the server, then tell every client to simulate a bullet for that player who fired it simultaneously.
When the bullet detects a hit on the client that fired it, validate that hit on the server through some sanity checks (i.e. check if it went through a wall, was too far away, was fired on a player that they shouldn’t have vision on, etc.) If it doesn’t pass the sanity check, then flag that player for a sus shot, and if they have lots of flags then kick them. (I don’t suggest banning as false positives always exist)
Of course, you’ll need to do some extra stuff to ensure the bullet hits don’t look wonky for other players (i.e. ghost hitboxes).
I suggest using FastCast for projectiles, by the way. They help a lot with modeling projectile bullets and handling hit detection.