Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I have a problem with GetPlayingAnimationTracks can someone help me?

I use this script to start an animation on someone

AnimationId = "ID"
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://"..AnimationId
local k = Workspace.Dummy.Humanoid:LoadAnimation(Anim)
k:Play()

and this one to copy the animation

local Services = {PLS = game:GetService("Players")}
local Player = Services.PLS.LocalPlayer
local Mouse = Player:GetMouse()
local Psj = Player.Character

Mouse.Button1Down:Connect(function()
local A = Mouse.Target.Parent or Mouse.Target.Parent
    if Services.PLS:GetPlayerFromCharacter(A) then
 local Ani = A:FindFirstChild("Humanoid"):GetPlayingAnimationTracks()
 local ANIL = Psj:WaitForChild("Humanoid"):LoadAnimation(Ani)
    ANIL:Play()

    ANIL.TimePosition = Ani.TimePosition
    
    end
end)

someone could help me fix it

1 answer

✓ Accepted answer

Hey man, it looks like you are trying to use 'Ani' like it is a singular AnimationTrack; However, :GetPlayingAnimationTracks() actually returns a list of all playing animation tracks.

You would have to iterate through the returned list and find the track you want to copy.

for i, track in pairs(Ani) do
	-- do what you need to do here
end

1 comment

0

LoadAnimation requires an Animation object.

This discussion is preserved as it was. New answers, comments, and votes are closed.