NetworkOwnerShip Lag

There has been a problem in my game where there is overall lag and chopiness among the NPC characters and the ball. I’ve included a video to showcase the issue below. As you can see, all the players are laggy and the trajectory of the ball is completely off and choppy.

The network ownership of all the characters parts(including the jersey models) and the football are set to the server and I have not been able to find any solutions.

If anyone has any suggestions for a solution to this, I would greatly appreciate it.

Is the lag being caused by the scripts or is it physics based do you think. You can check if it is script based by pressing F9, select Scripts from the dropdown and check the Activity and Rate/s. For Physics issues, you might need to check the Microprofiler

I would have to assume it would be a physics-based issue, as I’m not experienced with reading the micro profiler, but the script activity and rates are not alarmingly high.

Also, I don’t know if this helps point out if it’s a physics or script issue, but the game works perfectly fine in the studio, but in-game it is choppy and laggy as shown in the clip.

That could point to a replication issue if it is fine in Studio but not online. When playing online, press Ctrl+F7 and check the Sent & Recv info. This represents how much info the server is having to send to the client to update it. This should hopefully be a fairly low value.

For example, 2 version of the same game, but with varying numbers of NPCs:
15 NPCs:

25 NPCs humanoids + 15 NPC cars

That doesn’t seem to be the issue, as both values are low:

Can you show the Script output from F9 for us to see.

Another thing to add: this problem did not begin to occur until I added the 3D Jerseys that you can see in the clips.

Yeah activity seems low even though Rate/s seems high overall for some scripts. For the 3D Jerseys how are they added? Are they meshes attached or are the Accessories?

Either way, ensure that CanCollide, CanQuery, CanTouch and CastShadow are turned for for all of them.

This simple change seemed to fix the problem mostly, but it still occurs sometimes what do you think I need to do to fix it completely?

Probably time to learn the MicroProfiler, or at least look at the stats and see if something really obvious stands out. I would expect you would see something obvious as they seems to be a rela lag at certain points.

What does the Masterscript do? The second video doesn’t seem to show as much pronounced lag by comparison to the first. How do the NPCs determine their destination? Are you sure you have optimised the targeting as much as possible?

What would I look for exactly in the MicroProfiler?

The MasterScript uses an API I made to move the NPCs when the play is started. I feel I could optimize the targeting even more, but I feel like since this didn’t occur until I added more parts I think this is a physics issue rather than a scripting issue.

An old but relevant post here:

I know this is a little late, but I was still having trouble with this and did more research and I think I found that the ultimate issue is physics throttling. Any tips on how I could solve this?

It seems odd as it does not look like you have a large amount of parts in the game. Does each NPC part have collisions set on them (ie each limb part)?

To check the physics load on the server use the following in a separate script:

while true do
	print("Physics", workspace:GetPhysicsThrottling())
	task.wait(0.1)
end

This will return a value 1 > 100 with 100 being OK. This will allow you to see the throttling in realtime and not need the Microprofiler.

I’ve got at least 35 NPCs and a further 25 NPC vehicles roaming a workspace with no physics lag. However, all NPCs are in a single collision group and set not to collide with each other.

Each NPC has all of their limbs CanTouch properties set to false and they each have one big hitbox block. I realized that the lag is very inconsistent as sometimes its the ball, and sometimes its the characters themselves moving slow as I was trying to gather clips for you. It returns 100 almost always and there is occasionally drops to 75 or 87.

One playthrough the game will work perfectly fine, but another one the NPC’s could lag or the ball could lag.