So every one of my guns use a local script that fires remoteevents/remotefunctions to a server script. It feels like some bullets are not shown when two people are shooting at the same time. As well as smoke particles that pop up where the bullet holes are sometimes get delayed. The bullet hole shows up but the emitter is delayed.
It depends on what system you have. My weapon framework uses Roblox Tools as guns, so they each have their own ServerScript for bullet spawning.
Also, as a side note, I would suggest firing the bullets on the client and handling hit detection on the server to prevent exploiters from killing everyone.
The only thing given by the client is the mouse position, hit markers and other UI displays. Everything else for me is handled on the server. The bullet object, the hit detection, and the effects like smoke and gun flash. Is it too much for the server to handle? Would it make a difference if each gun operated on their own server script vs if they all operated on one server script?
It’s less about server lag and more about which tasks are handled first. Don’t take my word for it though - check out some of the other weapon tutorials on the Devforum for more information.
How do you move your bullets?
Normally when you are scripting, there are some small details that you forget, and
after alot of research you figure it out, check out all scripting once in a while and see if
everything is correct and everything makes sense, if you made some script that you got
kinda confused while making it, then probaly it will be an issue if bad scripted
I use tween service to move the bullets. I also use delays a lot. Would this cause issues?
if lightFlash then
flash.Enabled = true
lightFlash.Enabled = true
delay(flashtime,function()
if currentVal == currentShot.Value then
lightFlash.Enabled = false
flash.Enabled = false
end
end)
end
No, the last thing you want to do is tweening your bullets, tweening requires a lot of calculating to do and it does lag if abused - these are one of those instances.
What you need to be doing is to use FastCast + PartCache for bullets and if you don’t want that, then there’s Part Velocity to play with.
I use RunService.Heartbeat, it’s lag-free and easy to set up.
Im sure thats on the client though? Using heartbeat on the server would be expensive wouldn’t it? @SharpSerious I’ve never used that module and not sure how it works so id prefer to use one that I made myself, but I’ll keep that in mind.
Uhhhhhhhh… idk about server lag but what I do is I simulate the bullets on the clients and then make a transparent bullet for hit detection on the server.
Do you simulate the bullet so every client can see it? I think having the bullet simulate on the client would def take some load off the server except now you cant really see other people’s bullets. Also what I noticed to cause the problem is the dust particles that kick up from the ground where u shoot. I’m gonna try having them operate in a separate script and see if that works.
My weapon system actually has such a particle effect system.
I will leave a link to my game which uses this system soon.
In the beginning of the video the dust particles show up as expected, but later on you’ll notice some of them are delayed.
I’ve split it all up to isolate the problem, but it doesn’t make sense to me why it keeps delaying.
Server script which is the child of the bullethole so it fires the client as soon as its created
local dustEvent = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").Dust
local bullethole = script.Parent
dustEvent:FireAllClients(bullethole)
Client
function bulletDust(bullethole)
local emitter1 = bullethole.Attachment.Smoke1
local emitter2 = bullethole.Attachment.Smoke2
emitter1:Emit(5)
emitter2:Emit(1)
end
dustEvent.OnClientEvent:Connect(bulletDust)
At first I thought well it could just be my ping, but as seen in the video some of the bulletholes were already created then 6 seconds later the dust particles finally appear. And my ping definitely never went passed 6000 or even close to 1000.
My suggestion would be to simulate hit detection with particles only on the clients, so no events are fired. I believe that’s causing the delay. You can do damaging and advanced hit detection on the server.
Here’s a link to my FPS which uses my weapon framework: Testing - Roblox