In the current gun system im making the client makes a bullet and calculates the path. Then it sends a remote to the server telling it to make its own bullet, server then also tells the other clients to make there bullets. The servers bullet is invisible and also goes on a path its going to calculate.
When the clients bullet is hit it tells the server if the hit part is a person or not and destroys its local bullet. The server then does a region3 on the bullet expanded by 5 studs (to account for it not being sync with the client). If there is a player in the region and the players name is the one sent by the client the server does damage on the player. And destorys the server bullet.
Now the problem is I cant add random recoil values ect, since the server and the client have different bullet models. The problem with calculating it on the server and making the other bullets have the same position as the server calculated value is the noticeable delay, and the projectile won’t go in the same path as the shooter expected.
I had to tackle a similar issue, but what I would do is just change how you handle bullets.
What I did was make a tool with a Client Script, a Server Script, and a RemoteEvent. In the client script, I basically just created a raycast whenever the tool was activated, which was the bullet. I created the bullet and then fired a RemoteEvent. This RemoteEvent also sent a CFrame and the Raycast used along with it so that there won’t be a delay in terms of the positioning. The Raycast also had randomized recoil values along with it.
Oh the hit detection I made is using raycasts it’s somehwhat similar to the fastcast module.
So basically what your suggestiing is everytime the bullet moves to the next point in the path, send a raycast and the randomized values such as recoil, and the bullet position.
There is one problem with this though, the client can easily spoof the values since there isn’t really any way to check on the server, If this was instant hit bullets then I could have casted a ray from the starting to the ending, but these aren’t and have slower projectile speeds, and they don’t all travel in linear fashion some of them travel in projectile motion
An other problem is that the delay would be pretty big for other clients since the player client would have to send the info to the server and the server would have to update the info to all the clients (except the the shooter).
That’s fair. In all honesty I don’t really know if there is any good way to actually implement random recoil values without making it easy for people to spoof the value.
I was testing about your claim on how there would be a delay for the other clients, and I couldn’t really find anything. Unless this has something to do with the amount of players in the server and the amount of bullets being shot.
Oh ok, since my paths are projectiles and ect I would raycast to the next point of the path in the equation, send that to the server, and then server would send it to other clients, while doing some validty checks
Alright so I have found a more elegant solution. Using the new roblox Random object, the thing will always return the same values with nextingerger with the same seed. For example, first time I call nextinteger it returns 2 next time it returns 6 ect. However these values are based on the seed, so if the server got the same seed it would return 2 and then 6 to.
So all I do is send this seed to the server, and the clients. When they wanna change there paths they use NextInteger() keep in mind all the bullets will have to have the same movement code for this to work, for example the if the client one is using the random object but the server one isn;t it won’t work.
The way I thought of this idea is a simple logic I missed. If two objects start at the same state and simulate the same paths they end up at the same destination. They don’t need to replicate if they have the same movement code. For example if the server one destorys the bullet 1 out of 8 chance and the client one has that in it’s code to, it will work since they are using the same seed.