if table.find(Target.Humanoid.Animator:GetPlayingAnimationTracks(), value.Name) then
Target.Humanoid.Animator:GetPlayingAnimationTracks() is this
[1] = WalkAnim
value.Name is a string which is
WalkAnim
table.find returns nil
if table.find(Target.Humanoid.Animator:GetPlayingAnimationTracks(), value.Name) then
Target.Humanoid.Animator:GetPlayingAnimationTracks() is this
[1] = WalkAnim
value.Name is a string which is
WalkAnim
table.find returns nil
table.find doesnt search for values. it searches for the index. in the table, the VALUE WalkAnim has the INDEX of 1. if you put 1 in the table.find then you will get a true boolean
If you’re saying you put the index into table.find, you’re wrong. table.find returns the index of the given value.
The OP is using it incorrectly because they are passing a string, the animation’s name, instead of the animation itself. table.find should return the index of the track should the track be provided.
@aeroactual, try this and lmk
if table.find(Target.Humanoid.Animator:GetPlayingAnimationTracks(), value) then
still not working
Value is the same animation thats being played in the table; idk why not working
would you mind sending the full code? fyi i did test my previous statement and it worked, curious to see what could be causing the issue for you
oh dang i messed up lol. i have no idea why i said that. op listen here boy
messy code
saves the current animation table here of a Character
RecordedEvents[#RecordedMovement] = LocalCharacter.Humanoid.Animator:GetPlayingAnimationTracks()
it goes through saved animation Table and checks if its currently playing on a different character then trys to play animation on that character
if RecordedEvents[index] then
for index, value in pairs(RecordedEvents[index]) do
if not value.Animation then
--wip
end
if value.Animation then print(table.find(Target.Humanoid.Animator:GetPlayingAnimationTracks(), value))
print(value, "TEST")
if not table.find(Target.Humanoid.Animator:GetPlayingAnimationTracks(), value) then print("is")
Target.Humanoid.Animator:LoadAnimation(value.Animation):Play()
end
end
end
end
So you’re checking the same animation track against different characters?
All the tracks will be different when played on different characters - they’ll all have different locations in memory and refer to different characters internally. What you can do, is if they all use the same animation instance, you can check that or if not just check the animation instance’s AnimationId.
If I misunderatood, please let me know.
Probably because GetPlayingAnimationTracks returns an array of animation tracks but you’re looking for a string. It’s a type mismatch. To search using table.find you need to convert value.Name to an animation track present in the array or loop through everything and compare their .Name property:
local function findAnimationTrack(animationTracks: {AnimationTrack}, name: string): AnimationTrack?
for _, track in pairs(animationTracks) do
if track.Name == name then return track end
end
return nil
end
local tracks = Target.Humanoid.Animator:GetPlayingAnimationTracks()
if findAnimationTrack(tracks, value.Name) then
print("Found!")
end
How would i do this ? thrity MM
i’d prefer not using a loop for it but is that the best way?
A loop seems like the best option here.
Here’s a quick function to check all of the tracks playing on an Animator for the animation:
local function trackIsPlaying(animator: Animator, animation: Animation): boolean
for _, track in next, animator:GetPlayingAnimationTracks(), nil do
if (track.Animation == animation or track.Animation.AnimationId == animation.AnimationId) then
return true
end
end
return false
end
Ive gotta sleep now so i prob wont reply for a few hours sorry
no worries, thanks for help so far
this worked Ty alot for the help