Cannot store an animationTrack

Hey, I’m trying to do make some sort of fighting script, it mostly work except for the animations :I’m trying to create the animation track when the character is created and store them in a table so that I can play them randomly
Capture d’écran 2023-02-22 à 16.39.37

My issue is, I can’t store the animationtrack in the table and play it, I’ve tried to make the script into a server script and a module script and the animation doesn’t play in both cases, I’ve also tried to play a specific animation stored into a variable which still doesn’t work.
The only case when it work is when I use load the animation directly when the function run, the problem being that the number of animation track loaded is limited.

Is it “normal” and is there any way to get around it ?

In case this is important, here is the part of the script to choose the animation and what it returns :
Capture d’écran 2023-02-22 à 16.45.55
Capture d’écran 2023-02-22 à 16.46.24

Thanks in advance

What is the error?

Did you return the animations table in your function?

That’s the problem, there is no error, the animation just doesn’t play
and i’ve sent what is returns when I print the table in the last screen

Have you checked other posts on animation not playing?

I haven’t search that much so no but from what I see it doesn’t give me a solution :the animation priority shouldn’t be wrong, same for permissions as it’s published in a group for a group game (as I said, it works when I load the animation each time the function is called, but not when I store it)
I will search into more posts though

I think you should create a variable where you load the animation track and put it into your table, maybe that would change something ?

I already tried, but that’s the same :actually I’ve also tried to create a variable which contain the loaded animation and play only this specific animation with the variable in the script but this change nothing, the only option I have found to play this is to load the animation each time I fire my fighting function

1 Like

But are you firing the table to client or no ?

Can you show us all the code so I would be able to help you ?

Sorry, I’m not sure to understand, I load and play the animation into a script (I’ve also tried that with a module script used by a server script) and store them into a variable so that another function of this script use them.
Everything at this point is made from the server, and not the client

1 Like

Capture d’écran 2023-02-22 à 17.51.54
So these are the variables and the function that should load the animation and put it into the table


And here is a part of the script that contains the code and should choose the animation being played (as you see I’ve tried to play only a specific animation but that still doesn’t do anything)

Why aren’t you playing your animation by the client side and can you post your script like this :

hello

In the code I’ve quoted, you create a global variable animations that I don’t see any other reference to in your module. Make sure that it is saved in the module table

Because the way the script work is that it use animation keyframe’s name to know when the server’s code after that (so making damages and playing effects) should be executed

That was not the original script, I’ve tried to create a table which would not be into the module like you see in my first post but that’s not so different, the original code should be something like this (yeah I have many diferents version sorry)
Capture d’écran 2023-02-22 à 18.04.07

How are you receiving module? Also, are you calling initialize?

the function is called by a server script each time the player spawn/respawn :
Capture d’écran 2023-02-22 à 18.11.51

And yeah I’m sure the initialize function is being used, because the table is not empty when I try to play the animation

I have made a script that does the same thing that your initialize function :

local Players = game:GetService("Players")
local AnimationTrackTable = {}

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Animator = Character.Humanoid.Animator
		local Strike1, Strike2, Strike3, Strike4, Strike5 = Instance.new("Animation"), Instance.new("Animation"), Instance.new("Animation"), Instance.new("Animation"), Instance.new("Animation")
		local Table = {Strike1, Strike2, Strike3, Strike4, Strike5}
		Strike1.AnimationId = "rbxassetid://12544286908"
		Strike2.AnimationId = "rbxassetid://12544367373"
		Strike3.AnimationId = "rbxassetid://12544477100"
		Strike4.AnimationId = "rbxassetid://12552682977"
		Strike5.AnimationId = "rbxassetid://12555321710"
		for v, Animation in pairs(Table) do
			Animation.Name = "Strike"..v
			local AnimationTrack = Animator:LoadAnimation(Animation)
			AnimationTrackTable[v] = AnimationTrack
		end
	end)
end)

print(AnimationTrackTable)

I have do this and it works :

local Players = game:GetService("Players")
local AnimationTrackTable = {}

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Animator = Character.Humanoid.Animator
		local Strike1, Strike2, Strike3, Strike4, Strike5 = Instance.new("Animation"), Instance.new("Animation"), Instance.new("Animation"), Instance.new("Animation"), Instance.new("Animation")
		local Table = {Strike1, Strike2, Strike3, Strike4, Strike5}
		Strike1.AnimationId = "rbxassetid://12544286908"
		Strike2.AnimationId = "rbxassetid://12544367373"
		Strike3.AnimationId = "rbxassetid://12544477100"
		Strike4.AnimationId = "rbxassetid://12552682977"
		Strike5.AnimationId = "rbxassetid://12555321710"
		wait()
		for v, Animation in pairs(Table) do
			Animation.Name = "Strike"..v
			local AnimationTrack = Animator:LoadAnimation(Animation)
			AnimationTrackTable[v] = AnimationTrack
		end
		AnimationTrackTable[1]:Play()
		print(Animator:GetPlayingAnimationTracks())
	end)
end)

Okay, so I’ve modified my script like yours, still doesn’t work :here is what it returns
Capture d’écran 2023-02-22 à 18.27.58
Capture d’écran 2023-02-22 à 18.28.42

(just in case, that’s basically the same thing as your script but here is the function I’ve made based on yours)

1 Like