Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have a problem with GetPlayingAnimationTracks can someone help me?

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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
0
LoadAnimation requires an Animation object. RADDIACTIVE 2 — 5y
Ad

Answer this question