UPDATE: This change is not live yet but is still planned.
In late May we are going to make some changes to the ordering of events that are fired during the avatar loading process. We will announce the exact date for this change closer to when it is going to go live.
The aim of this change is to make the avatar loading event ordering easier for developers to understand and to make it easier to write code which interacts with avatar loading. Currently there are a number of idiosyncrasies with avatar loading, for example the avatar is not in the
Workspace when the
CharacterAdded event is fired and the avatars rig is not finalized when the
CharacterAppearanceLoaded event is fired. These idiosyncrasies can lead to bugs when developers write code which interacts with the avatar loading process and make it more difficult to achieve some use cases.
With the new event ordering we will add the avatar to the DataModel only after the avatar position, rig and appearance are finalized. Then the
CharacterAppearanceLoaded events will be fired.
Current Ordering New Ordering 1. Call LoadCharacter Call LoadCharacter 2. Player.Character is set Character appearance is initialized 3. CharacterAdded fires Character rig built/character scaled 4. Player.Character changed event Character is cframed to spawn location 5. Character appearance is initialized Player.Character is set 6. CharacterAppearanceLoaded fires Player.Character changed event 7. Character parented to DataModel Character parented to DataModel 8. Character rig built/character scaled CharacterAdded fires 9. Character is cframed to spawn location CharacterAppearanceLoaded fires 10. LoadCharacter returns LoadCharacter returns
This new ordering fits a few common use cases much better than the current event ordering:
- Applying character appearance items can be done easily without worrying about interference from the avatar loading code.
- Assigning custom collision groups for the character when it is added will be easier as the rig will be guaranteed to be finalized.
- Using APIs that require the character to be in the DataModel can be done immediately after
CharacterAdded, an example is loading animations for the new character with the
- Custom spawn positioning can be done by listening to the CharacterAdded event and moving the character immediately.
This change could break code which is relying on the current ordering of events. For example, this will break code which is waiting for the character to be added to the
Workspace as follows.
player.CharacterAdded:connect(function(character) -- With the new ordering AncestryChanged won't be fired because the character will already be in the Workspace character.AncestryChanged:wait() -- do stuff end)
The changes required to so that code is compatible with the new event ordering should be minimal, the above example can be changed to the following during the migration period.
player.CharacterAdded:connect(function(character) -- When the new ordering is enabled it will be guaranteed that the character is in the Workspace when CharacterAdded is fired. -- This check is temporary to migrate from the old event ordering if not character.Parent then character.AncestryChanged:wait() end -- do stuff end)