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

How to do a pairs function with 2 variables?

Asked by 3 years ago
Edited by raid6n 3 years ago

To don't have a lot of load animation, I need a pairs function who search animation, this is my script:

anim = humanoid:GetPlayingAnimationTracks()

for i, track, track2 in pairs (anim) do

if track.Name == "Stand" and track2.Name == "Walk" then

track:Stop() 

track2:Play() 

end

end

And in output this said "tried to call a nil value with track2.Name" So how can I do, please?

2 answers

Log in to vote
1
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

You're doing it incorrectly. Here's an example of how to do a in pairs loop.

for i, v in pairs(workspace:GetChildren()) do
    print(v.Name) -- prints everything in workspace
end

Edited code:

anim = humanoid:GetPlayingAnimationTracks()
for i, track in pairs(anim) do
    if track.Name == "Stand" then
        track:Stop()
    elseif track.Name == "Walk" then
        track:Play()
    end
end

Ad
Log in to vote
0
Answered by 3 years ago

Thanks, but this don't work because I want stop an animation then play an animation, but with this script, only the animation is stopped or is played.

Answer this question