Hi, I’m working on an outfit-type game, and I’m stuck on loading animations using HumanoidDescription
. I’ve already fetched all the animation bundles from Roblox, but when I try to apply them, I get an error.
This is my code for loading animations (server-side):
function Module._updateAnimations(player: Player, bundleId: number)
-- Check if player is valid | SERVER
if not I.Player.Valid(player) then
return
end
--[[ Getting Humanoid ]]
local character = player.Character
local hum: Humanoid = character:FindFirstChildOfClass("Humanoid")
local humDesc: HumanoidDescription = hum:GetAppliedDescription()
if not humDesc then
return
end
--[[ Getting Animations Bundle Folder ]]
local catalogStorageFolder = I.Dirs.UmeReplicated:FindFirstChild(_localName)
local bundlesFolder = catalogStorageFolder and catalogStorageFolder:FindFirstChild("AnimationBundles")
local animationsFolder: Model = bundlesFolder and bundlesFolder:FindFirstChild(tostring(bundleId))
if not animationsFolder then
return
end
--[[ Updating Animations ]]
for _, strVal: StringValue in ipairs(animationsFolder:GetChildren()) do
if strVal.Name == "idle" then
local anim1 = strVal:FindFirstChild("Animation1")
local anim1Id = anim1 and string.split(anim1.AnimationId, "?id=")[2]
local anim2 = strVal:FindFirstChild("Animation2")
local anim2Id = anim2 and string.split(anim2.AnimationId, "?id=")[2]
if anim1Id then
humDesc.IdleAnimation = tonumber(anim1Id) or 0
end
if anim2Id then
humDesc.MoodAnimation = tonumber(anim2Id) or 0
end
else
local anim = strVal:FindFirstChildOfClass("Animation")
local animId = anim and string.split(anim.AnimationId, "?id=")[2]
if animId then
humDesc[animNames[strVal.Name]] = tonumber(animId) or 0
end
end
end
--[[ Applying ]]
hum:ApplyDescriptionReset(humDesc)
end
I get the following error:
Where should I put the R15Anim
folder? Or should I be using a different method?