I have this Lua code for a combat system:
local comboCount = 0
function CombatSystem:GetAnimationForHit(hitNumber)
local animations = {
[1] = "rbxassetid://133302675095894",
[2] = "rbxassetid://86675730184536",
[3] = "rbxassetid://1234561",
[4] = "rbxassetid://1234561",
[5] = "rbxassetid://1234561"
}
return animations[hitNumber] or animations[1]
end
function CombatSystem:PerformAttack(player)
comboData.count += 1
-- ===== Play Animation =====
local animationId = self:GetAnimationForHit(comboData.count)
local animation = ReplicatedStorage.CombatSystem.AttackAnimation
animation.AnimationId = animationId
animator:LoadAnimation(animation):Play()
end
My question is:
Is it bad practice to use a single animation instance and just change its AnimationId depending on the player’s combo? Or is it better to create multiple animation instances and set them up when the player joins?