Why does this work in current server, but not with player to player?

With your guy’s help, I created a smooth bullet ejection script. Now, there’s another problem that comes up. I can clearly see the bullets in the server, which I switch from client to server in the testing tab, but when I do the 2 player testing, the other player can’t see the other bullet casings. Why is this? And how do I fix this?


2 Player Testing:

Are the bullets being created from the local or server side?

It looks to me like you’re deleting the bullets on the other client’s screen. The bullet briefly shows and then disappears in te second player’s screen. What does your current implementation entail?

So far, the gun makes two bullets, one for the client, and one for the server. The one for the server gets deleted locally so that the shooter sees the smooth version, while the server sees the laggy version. It works if you switch to the server during testing mode, but on other player’s screens, it doesn’t work.

Both, but the server bullet is just being deleted from the client, so the shooter sees the smoother version, while the server sees the laggier version.

If you’re creating the same bullet from both the client and the server, you’re essentially duplicating that instance.

There’s multiple ways to go about this which each having differing expenses. You could create the bullet on the server and delete it after it hits the ground (use raycasts (magnitude == 0) and not .Touched for this). You could also create this on the client and push to all clients and delete it after a certain amount of time.

However, without a code snippet, this is an educated guess.

Hope this helps!

Oh, since I didn’t know what to do, I just put a temporary solution. I fired a remote from a local script whenever the gun fired and this is the server script:

local DebrisService = game:GetService(‘Debris’)
local shell2 = game.ReplicatedStorage.bullet
local shell = shell2:Clone()
shell.CFrame = script.Parent.Bullet.CFrame * CFrame.fromEulerAnglesXYZ(1.5,0,0)
shell.CFrame = script.Parent.Bullet.CFrame
shell.Anchored = false
shell.Name = “Shell”
shell.Velocity = script.Parent.Bullet.CFrame.lookVector * 35 + Vector3.new(math.random(-10,10),20,math.random(-10,20))
shell.RotVelocity = Vector3.new(0,100,0)
DebrisService:AddItem(shell, 5)

shell.Parent = game.Workspace


Hope this will help others to find a solution for this lag problem.

You should create your shell on the server (like you have) and apply your code to it via the client. Stuff like that should always be done locally. If you were to have more than one player firing at various rates, the server wouldn’t be able to keep up.

I tried applying the local script to the client, but it just deletes the shell casing for both the client and server.