fix CreateModel character spawn delay & memory leak #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
modelPool
did not function as a player's model pool is removed each timeDestroyModel
is ran. this made the function reapply the same humanoid description each respawn, delaying respawning client-side for up to a second due toGetHumanoidDescriptionFromUserId
&ApplyDescription
- this delay is especially notable when a player's visiblity callback (CanPlayerSee
) changes, in which case it will cause a very noticeable delay when the player model needs to be spawned in againadditionally, while
modelPool
is removed its model parented in lighting is never destroyed and a new model would continue to be created on each client each time a player respawns and are never cleared until the client rejoinsI had made it so the cached model updates its humanoid description after each respawn to still sync with player's roblox avatar, although it now takes 2 respawns to load in a new avatar rather than 1 respawn