There are a few optimisations you could make to make it run better:
- instead of outright cloning the character, only clone the
BasePart
s and put those in a new model. - instead of iterating through the workspace every frame, iterate through players (if you only want pvp combat) or use tag every model with a humanoid and then iterate over
CollectionService:GetTagged("name of humanoid tag")
. - Instead of using a different
WorldModel
for each character put all the characters in the same WorldModel for each frame. - if you want you could also also make a new WorldModel every couple milliseconds instead of every frame (this depends on how much accuracy you want to have as opposed to performance)
- if you put all the character clones in the same WorldModel, having the character name as part of the name of the WorldModel would be redundant, so you could just name it the
tick()
it was created on, which means you also don’t have to split the string each frame.