It is multi-threading, but there’s still only one thread running at a time. With parralel lua, you can actually have multiple threads running at once. This might not make lag better for the server though.
task.delay(0.25, function()
while true do
-- Lua never leaves this thread
end
end)
task.delay(0.5, function()
print("Success!") -- Never printed
end)
There’s a few things to try:
Trust the client to create and animate NPCs, but the server handles everything else about the NPC
Well. I don’t know what you have already done. But here are some suggestions.
Try spawning all the zombies on the client. Have server say where when they spawn and plan the route. They also will probably need an ID so that you can talk about specific zombies easier. This can reduce network traffic by quite a bit since you can compress the information a lot more.
If possible remove the humanoid. That comes with some extra processing if I recall correctly and managing to make the zombies without it might speed it up. Also anchor the zombies and move them by CFrame directly.
Do you need to draw every zombie? I’d experiment with ways to get away with not updating zombies and potentially not even drawing some of them. (When the zombies are that dense you might be able to get away with only drawing 2/3 or 1/2 of the zombies (though this would be tricky since you need the last zombies to always be drawn so you either need to ensure the invisible ones get targeted first or that they get drawn when density gets low enough but that could lead to a pop in. you could also try just drawing the head of those zombies instead of making them invisible and give them the rest of a body when density lowers)