(topic deleted by author)
I apologize if I missed this info, but how many npcs are you cloning into workspace? If youâre cloning a large amount of objects with humanoids, that will start causing significant lag problems and youâd need to find an alternative to making npcs without humanoids. If itâs only a couple though then there will be no issues with lag.
My other initial thought is that the lag has to do with the MeshParts referenced in the code, try preloading the meshes on the client before doing any cloning on the server, MeshParts are also typically a culprit of lag, especially if youâre cloning a large amount of unloaded MeshParts at once.
Hmm. Alright. Also, this is just a model. It doesnât contain a âHumanoidâ Instance in it.
Also, itâs just one model. The MeshParts are in one singular model. Not multiple.
If you are woried about the lag caused by cloning too many parts you should think about using PartCache to reduce it, also TweenService might cause lag too if you are trying to tween too many parts at once so switching the tween to a local script would be less expensive for the server.
Thanks for that. Just got the script. Question. What movement method would you recommend? (For anyone that sees this, you can also give your suggestions) Someone told me that this code block caused my game to lag a lot. Is this true?
Supposed âLag Code Blockâ:
local Part = script.Parent
for i = 1, 250 do
Part.CFrame = Part.CFrame * CFrame.new(0, 0, 2)
task.wait()
end
game.Debris:AddItem(Part, 0)
Hm, this block of code could potentially make your game lag depending on how many parts you run it at once, also it appears to me that this part you are moving is sort of a purely âvisual effectâ, am i right? If so you could handle all itâs movement on the playars side to avoid laggin the server.
Maybe using TweenService V2 could help, it tweens the part on the client side and on the server side it handles the tweenâs property changes once the tween is completed. It really depends on what you are using those parts for.
Additionally i dont think thereâs a need to use the debris on the bottom of your script, changing it with Destroy or calling PartCacheâs ReturnPart would have the âsame effectâ. I hope it helps you!