I know the title is extremely confusing, but allow me to elaborate;
i have a KeyframeSequence
stored inside server storage, and its priority is Action4
:
however, when loading in the animations during testing, their priorities are set back to Action
i tested this a bit, and this only happens with my attack animations
(Heavy
is an attack animation; Base
is a chase animation)
sure, a simple fix would be to just do track.Priority = Enum.AnimationPriority.Action4
, but i actually want to find the culprit of the issue here
i’m not exactly able to pinpoint any issues in my code, since all it does is just roll an animation, and play it:
-- // MODULE \\ --
function utility.RNG(tableOfChances: {Instance: {number}})
local totalChance = 0
for _,chance in tableOfChances do
totalChance += chance
end
local rng = math.random(1, totalChance)
for option,chance in tableOfChances do
rng -= chance
if rng <= 0 then return option end
end
end
-- // SERVER-SIDE \\ --
local function GetEnemyComponents(enemy: Model)
local animations: Folder = enemy:FindFirstChild("Animations")
local attackAnimations: Folder = animations and animations:FindFirstChild("Attacks")
local sounds: Folder = enemy.PrimaryPart:FindFirstChild("Sounds")
local values: Folder = enemy:FindFirstChild("Values")
return animations, attackAnimations, sounds, values
end
local function HandleMeleeCombat(enemy: Model, rootPart: BasePart, enemyData: {any})
local enemyAnimations, attackAnimations, enemySounds, enemyValues = GetEnemyComponents(enemy)
local detectors: Folder = enemy:FindFirstChild("Detectors")
local combatDetector: BasePart = detectors:FindFirstChild("Combat")
local playersInPart: {Player} = utility.GetPlayersInPart(combatDetector)
if not playersInPart then return end
local enemyHumanoid = enemy:FindFirstChildOfClass("Humanoid")
if not enemyHumanoid then return end
local comboTrack, heavyTrack = LoadEnemyAnimations(enemyHumanoid, attackAnimations)
local animations = {
[comboTrack] = 60,
[heavyTrack] = 40
}
-- these are unused functions that have no code in them, so i am not including them
if PerformSpecialAttackIfReady(enemy, enemyValues, enemyData) then
return
end
if specialsModule.DodgeOrShoveIfPossible(enemy) then
return
end
local chosenTrack: AnimationTrack = utility.RNG(animations)
print(`the priority of {chosenTrack.Name} is {chosenTrack.Priority}`)
local markersToUse
if string.find(chosenTrack.Name, "Heavy") then
markersToUse = enemyData.heavyMarkers
elseif string.find(chosenTrack.Name, "Combo") then
markersToUse = enemyData.comboMarkers
end
-- this is responsible for damage output, but since the animation never reaches any marker because it instantly stops, i am not including this function
local markerConnection = SetupAttackMarkers(enemy, chosenTrack, markersToUse, rootPart)
local combatValues: Folder = enemyValues.combatValues
chosenTrack:Play()
combatValues.attacking.Value = true
--chosenTrack.Stopped:Once(function()
-- markerConnection:Disconnect()
-- combatValues.attacking.Value = false
-- combatValues.attackCooldown.Value = true
-- task.wait(enemyData.attackCooldown)
-- combatValues.attackCooldown.Value = false
--end)
end
my only theory is that this is a bug, and i have no other explanation