I’m trying to play an animation when my enemy attacks someone, but the animation isn’t playing. The default Roblox animate script is also included in here, I figured that might be the problem and messed with the weights but there were no results.
My script:
local repStorage = game.ReplicatedStorage
local quantityManager = require(repStorage.QuantityManager)
local humanoid = script.Parent.Zombieoid --humanoid is renamed for anti team kill
local rarm = script.Parent:FindFirstChild("Right Arm")
local larm = script.Parent:FindFirstChild("Left Arm")
local zombie = script.Parent
local hum = zombie.Zombieoid
local animation = script:WaitForChild("Attack")
local animationTrack = humanoid:LoadAnimation(animation)
local debounce = 0
local deathsound = zombie.HumanoidRootPart.DeathSound
local attacksound = zombie.HumanoidRootPart.AttackSound
local pitch = deathsound.PitchShiftSoundEffect
animationTrack.Priority = Enum.AnimationPriority.Action
function dmg(hit)
if hum.Health ~= 0 then
if debounce == 0 then
if hit.Parent ~= nil then
local hum = hit.Parent:findFirstChild("Humanoid")
if hum ~= nil then
debounce = 1
hum:TakeDamage(10)
animationTrack:Play()
attacksound:Play()
wait(1)
debounce = 0
end
end
end
end
end
The damage function is run when the enemy is touched, and I’m sure it’s activating because I take damage.
Any help would be appreciated, thanks