Skip to content

Commit e8f10e4

Browse files
authored
Update transferring-animations.md
1 parent c6d0d4d commit e8f10e4

File tree

1 file changed

+81
-81
lines changed

1 file changed

+81
-81
lines changed

content/en-us/projects/transferring-animations.md

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: Transferring Roblox Animations
33
description: Transfer animations when you transfer your experience to a new group owner.
44
---
55

6-
<Alert severity="info">
6+
<Alert severity="warning">
77
The instructions on this page make use of a third-party tool. Roblox does not officially support this tool and is not responsible for its availability, updates, or functionality.
88
</Alert>
99

1010
In Roblox, animations are locked to experiences owned by users who also own those animations. To prevent animations from breaking when you transfer your experience to a group, you must publish your animation assets to the new experience group owner.
1111

12-
If you have a large number of animations to upload, you can use the community-supported tool [Roblox Animation Transfer](https://github.com/evaera/roblox-animation-transfer) to re-upload the animations and map their old `AnimationIds` to their new corresponding `AnimationIds`.
12+
If you have a large number of animations to upload, you can use the community-supported tool [Roblox Animation Transfer](https://github.com/evaera/roblox-animation-transfer) to re-upload the animations and map their old `Class.Animation.AnimationId|AnimationIds` to their new corresponding `Class.Animation.AnimationId|AnimationIds`.
1313

1414
## Prerequisites
1515

@@ -19,35 +19,35 @@ For more information about prerequisites, see the [Roblox Animation Transfer REA
1919

2020
## Mapping AnimationIds to Names
2121

22-
If your animations are stored as Animation instances under pre-prepared Character models in your experience, you can generate a text file to map the `AnimationIds` to their corresponding names.
22+
If your animations are stored as Animation instances under pre-prepared Character models in your experience, you can generate a text file to map the `Class.Animation.AnimationId|AnimationIds` to their corresponding names.
2323

2424
1. In Roblox Studio, run the following script. Studio outputs the result as a single long string.
2525

26-
```lua
27-
local Workspace = game:GetService("Workspace")
28-
29-
local ANIMSTRING = ""
30-
31-
for _, character in Workspace:GetChildren() do
32-
if not character:IsA("Model") then
33-
continue
34-
end
35-
36-
local animations = character:FindFirstChild("Animations")
37-
if not animations then
38-
continue
39-
end
40-
41-
for _, animation in animations:GetChildren() do
42-
local animationId = string.match(animation.AnimationId, "%d+")
43-
if animationId then
44-
ANIMSTRING ..= (animationId .. " " .. character.Name .. "_" .. string.gsub(animation.Name, " ", "_") .. "\n")
26+
```lua
27+
local Workspace = game:GetService("Workspace")
28+
29+
local ANIMSTRING = ""
30+
31+
for _, character in Workspace:GetChildren() do
32+
if not character:IsA("Model") then
33+
continue
4534
end
46-
end
47-
end
48-
49-
print(ANIMSTRING)
50-
```
35+
36+
local animations = character:FindFirstChild("Animations")
37+
if not animations then
38+
continue
39+
end
40+
41+
for _, animation in animations:GetChildren() do
42+
local animationId = string.match(animation.AnimationId, "%d+")
43+
if animationId then
44+
ANIMSTRING ..= (animationId .. " " .. character.Name .. "_" .. string.gsub(animation.Name, " ", "_") .. "\n")
45+
end
46+
end
47+
end
48+
49+
print(ANIMSTRING)
50+
```
5151

5252
2. Create a new text file on your computer.
5353
3. Paste the string output by Studio into the text file.
@@ -83,68 +83,68 @@ After transferring your animations to the new group owner, you must swap the old
8383
2. Create two child modules, one corresponding to the user, or the original owner, and the other corresponding to the group, or the new owner.
8484
3. To prevent the experience from breaking if you choose to publish it to another location, run the following script. By default, the script returns the user's animations.
8585

86-
```lua
87-
local module = {}
88-
local GROUP_ID = 12345678
89-
local gameContext = {
90-
["User"] = require(script:WaitForChild("Animations_User")),
91-
["Group"] = require(script:WaitForChild("Animations_Group"))
92-
}
93-
94-
local function getAnimationMapForGameContext()
95-
if game.CreatorType == Enum.CreatorType.Group and game.CreatorId == GROUP_ID then
96-
return gameContext.Group
86+
```lua
87+
local module = {}
88+
local GROUP_ID = 12345678
89+
local gameContext = {
90+
["User"] = require(script:WaitForChild("Animations_User")),
91+
["Group"] = require(script:WaitForChild("Animations_Group"))
92+
}
93+
94+
local function getAnimationMapForGameContext()
95+
if game.CreatorType == Enum.CreatorType.Group and game.CreatorId == GROUP_ID then
96+
return gameContext.Group
97+
end
98+
return gameContext.User
9799
end
98-
return gameContext.User
99-
end
100-
101-
local animationMap = getAnimationMapForGameContext()
102-
function module.getAnimation(animName: string)
103-
return animationMap[animName]
104-
end
105-
106-
return module
107-
```
100+
101+
local animationMap = getAnimationMapForGameContext()
102+
function module.getAnimation(animName: string)
103+
return animationMap[animName]
104+
end
105+
106+
return module
107+
```
108108

109109
4. Turn the generated text files into animation maps in Studio.
110110
1. Replace the animation list inside the `animFileText` variable with the contents of the text file that you want to change into an animation map.
111111
2. Run the following script to return a string:
112112

113-
```lua
114-
local animFileText = [[
115-
4215167 Animation_Name_1
116-
6171235 Animation_Name_2
117-
1251267 Animation_Name_3
118-
]]
119-
120-
local function convertFileToAnimationMap(animFileText: string)
121-
local NEW_ANIMATION_MAP = ""
122-
123-
local lines = string.split(animFileText, "\n")
124-
for _, line in lines do
125-
local components = string.split(line, " ")
126-
if #components ~= 2 then
127-
continue
113+
```lua
114+
local animFileText = [[
115+
4215167 Animation_Name_1
116+
6171235 Animation_Name_2
117+
1251267 Animation_Name_3
118+
]]
119+
120+
local function convertFileToAnimationMap(animFileText: string)
121+
local NEW_ANIMATION_MAP = ""
122+
123+
local lines = string.split(animFileText, "\n")
124+
for _, line in lines do
125+
local components = string.split(line, " ")
126+
if #components ~= 2 then
127+
continue
128+
end
129+
130+
local animationId = components[1]
131+
local animationName = components[2]
132+
133+
NEW_ANIMATION_MAP = string.format("%s\t[\"%s\"] = \"rbxassetid://%s\",\n", NEW_ANIMATION_MAP, animationName, animationId)
128134
end
129-
130-
local animationId = components[1]
131-
local animationName = components[2]
132-
133-
NEW_ANIMATION_MAP = string.format("%s\t[\"%s\"] = \"rbxassetid://%s\",\n", NEW_ANIMATION_MAP, animationName, animationId)
135+
136+
return string.format("return {\n%s}", NEW_ANIMATION_MAP)
134137
end
138+
139+
print(convertFileToAnimationMap(animFileText))
140+
```
135141

136-
return string.format("return {\n%s}", NEW_ANIMATION_MAP)
137-
end
138-
139-
print(convertFileToAnimationMap(animFileText))
140-
```
141-
142-
5. Create a new `ModuleScript` parented to your `Animations` module.
143-
6. Place the returned `animFileText` string inside the `ModuleScript`.
142+
5. Create a new `Class.ModuleScript` parented to your `Animations` module.
143+
6. Place the returned `animFileText` string inside the `Class.ModuleScript`.
144144
7. Update the experience to source all animations through the `Animations` module by running the following script:
145145

146-
```lua
147-
local Animations = require(PATH.TO.ANIMATIONS)
148-
local warriorWalk = Instance.new("Animation")
149-
warriorWalk.AnimationId = Animations.getAnimation("Warrior_Walk")
150-
```
146+
```lua
147+
local Animations = require(PATH.TO.ANIMATIONS)
148+
local warriorWalk = Instance.new("Animation")
149+
warriorWalk.AnimationId = Animations.getAnimation("Warrior_Walk")
150+
```

0 commit comments

Comments
 (0)