I am trying to make an animation loader for my gun framework but i have an issue with getting the animations after they have been loaded.
Here is my animation loader:
local function loadGunAnimations()
while not GunHumanoid:IsDescendantOf(game) do
GunHumanoid.AncestryChanged:Wait()
end
if not GunHumanoid:IsDescendantOf(game) then
return
end
for _, Animation in pairs(GunAnimationsFolder:GetDescendants()) do
if Animation:IsA("Animation") then
GunHumanoid:LoadAnimation(Animation)
end
end
end
What you can do is store the loaded animations into a table:
local HumanoidAnimations = {}
local function loadGunAnimations()
while not GunHumanoid:IsDescendantOf(game) do
GunHumanoid.AncestryChanged:Wait()
end
if not GunHumanoid:IsDescendantOf(game) then
return
end
for _, Animation in pairs(GunAnimationsFolder:GetDescendants()) do
if Animation:IsA("Animation") then
HumanoidAnimations[Animation.Name] = GunHumanoid:LoadAnimation(Animation)
end
end
end
You can then play the animation like so:
HumanoidAnimations[AnimationName]:Play()
Or if you wish you can use the object as the index.
There is no method available for doing this, you need to manually track that yourself. If you’re having trouble predictably determining what animations play on a Humanoid, you can use AnimationPlayed and then log the playing AnimationTrack and its id in a table or dictionary someplace.
ty, i read that event a few days and i get a way for my problem, save every animation inside a table and changed the animator parent to the another humanoid and use the table to play the animations