Cannot store an animationTrack

I was wondering why are you writting this script on a module script ?

Because I could create a separate script for every type of attacks and manage those attacks in a main server script.
Again, I’ve also tried to make the code work with a normal script but the result is the same

1 Like

Ok, I think I would be able to help you if you let me test it and send it on the devforum like this :

With this thing i can paste your script and test it
local module = {}

module.count = 0
module.countwait = 1
module.using = false
module.cooldown = 0.3
module.tracks = {}

function module.initialize(c)
	module.tracks = {}
	
	--[[local strike1 = Instance.new("Animation", c.Humanoid)
	strike1.Name = "Strike1"
	strike1.AnimationId = "rbxassetid://12544286908"
	table.insert(module.tracks, c.Humanoid.Animator:LoadAnimation(strike1))
	
	local strike2 = Instance.new("Animation", c.Humanoid)
	strike2.Name = "Strike2"
	strike2.AnimationId = "rbxassetid://12544367373"
	table.insert(module.tracks, c.Humanoid.Animator:LoadAnimation(strike2))
	
	local strike3 = Instance.new("Animation", c.Humanoid)
	strike3.Name = "Strike3"
	strike3.AnimationId = "rbxassetid://12544477100"
	table.insert(module.tracks, c.Humanoid.Animator:LoadAnimation(strike3))
	
	local strike4 = Instance.new("Animation", c.Humanoid)
	strike4.Name = "Strike4"
	strike4.AnimationId = "rbxassetid://12552682977"
	table.insert(module.tracks, c.Humanoid.Animator:LoadAnimation(strike4))
	
	local strike5 = Instance.new("Animation", c.Humanoid)
	strike5.Name = "Strike5"
	strike5.AnimationId = "rbxassetid://12555321710"
	table.insert(module.tracks, c.Humanoid.Animator:LoadAnimation(strike5))]]--
	
	local Animator = c.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)
		module.tracks[v] = AnimationTrack
	end
end

function module.action(plr, player2, character, playerData)
	local action = character.Humanoid:WaitForChild("ActionState")
	if action.Value ~= "Idle" and action.Value ~= "GoingToAttack" and action.Value ~= "Attacking" and action.Value ~= "SpecialAttack" then 
		return 
	end

	local distance = (character.HumanoidRootPart.Position - player2.HumanoidRootPart.Position).magnitude
	if distance < 50 then
		local bg = Instance.new("BodyGyro",character.HumanoidRootPart)
		bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
		bg.P = 10000
		bg.D = 50  
		bg.CFrame = CFrame.new(character.HumanoidRootPart.Position, player2.HumanoidRootPart.Position)
		game.Debris:AddItem(bg,0.5)
		if distance > 4 then
			if character.Humanoid.FloorMaterial ~= Enum.Material.Air then
				character.Humanoid.PlatformStand = true
				delay(0.12,function()
					character.Humanoid.PlatformStand = false
				end)
			end
			local bp = Instance.new("BodyPosition",character.HumanoidRootPart)
			bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
			bp.P = 10000
			bp.D = 500
			bp.Position = player2.HumanoidRootPart.Position - character.PrimaryPart.CFrame.LookVector
			game.Debris:AddItem(bp,0.5)
		end
	end

	wait(0.1)
	module.count = module.count ~= 5 and module.count + 1 or 1
	
	local track = module.tracks[module.count]

	track:Play()
	print(track, module.tracks, character.Humanoid.Animator:GetPlayingAnimationTracks())
end

There can be some changes to make so that it run properly without every other scripts of the game but there it is

1 Like

I’m lost XD
Can you explain what you’re trying to achieve ?

I am trying to play an animation when I attack, for that I use a function that load the animations for the player, and store them into a table.
Then when I am trying to attack, one of the animations contained in this table would be played.
The issue is that I want to store the loaded animation into the table (and not the instance because if I load my animation each time I attack there will be another issue with the animation track limit), but for some reason I cannot and the animation doesn’t play

1 Like

For some reason if I simply add a wait before loading combat scripts and animations, it works.
Thanks for anyone who tried to help me.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.