How to reduce lag, from the developer side?

I have a first-person shooter game, and currently i had people complaining about having lag. The main resource consumers are the first-person framework of the gun, that is done using lerping and RunService.RenderStepped on the client-side, and the npc’s, that have a humanoid inside of them and a server script to move them along a predefined path using Humanoid:MoveTo(), there are like 15-20 npc’s moving. What could I do to reduce the lag? Also the gun shooting is handled by the server and done with raycasting, but I don’t know if that takes a lot of resources.

2 Likes

What kind of lag? How can they tell? It might be network lag instead of compute lag.

It may be the short distance between waypoints that causes the NPC lag. The pathfinding itself is best offloaded… I’m working on a service that can, optionally, run the pathfinding request on your behalf. You can follow the development progress here: Polaris-Nav

I think it is server lag, like high ping. It manifests in two ways : 1) delay when input in entered and 2) the teleport thing, where a npc like runs in place for a little bit and then teleports where it actually has to be. About pathfinding, i am not using pathfinding service. When I said predefined path, i meant i made a table with position and i am looping through the table and using Humanoid:MoveTo() and waiting until it reached it destination and go to the next point.

Also, i gave the internet ownership of every part of the npc to the server and the distance between every point that i set up is like approximately 15-25 studs in some rare cases it goes to like 5-8 studs and some other rare cases to 35-40 studs