[Solved]Animation Playing but the animation isnt playing correctly

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i want to play an animation (a hammer slam down) on an npc
  2. What is the issue? Include screenshots / videos if possible!
    the slam animation plays but is buggy (idk why)
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    ive tried switching a lot of stuff up with the anim, it didnt work (yes, i extended the end so it’s fully visible that the anim played)

Video Clips To Understand Problem:
How the animation is playing on the npc:


How it should be:

Code:

local M1Animation = script.M1Animation
local hammer = script.Parent.Hammer
local selfhumanoid = script.Parent.Humanoid
local humanoidbeingchased
local abilityrandomiser

function AttemptM1()
script.Parent.CanAttack.Value = false
script.Parent.HumanoidRootPart.Anchored = true
local M1AnimTrack = selfhumanoid:LoadAnimation(M1Animation)
M1AnimTrack:Play()
task.wait(2)
script.Parent.CanAttack.Value = true
script.Parent.HumanoidRootPart.Anchored = false
end

function M1()
--this is for damaging the player but not done yet	
end

script.Parent.AttackHitbox.Touched:Connect(function(hit)
	
	if hit.Parent:FindFirstChild("Humanoid") and script.Parent.ChasingSomeone.Value == false then
		
		humanoidbeingchased = script.Parent.HumanoidChasing
		humanoidbeingchased.Value = hit.Parent.Humanoid
		script.Parent.ChasingSomeone.Value = true
		
	end 	
end)

script.Parent.AttackHitbox.TouchEnded:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and script.Parent.ChasingSomeone.Value == true then
	if humanoidbeingchased.Value == hit.Parent.Humanoid then
		
		humanoidbeingchased.Value = nil
		script.Parent.ChasingSomeone.Value = false
		
		end
	end 	
end)

while task.wait(1) do
if script.Parent.CanAttack.Value == true and script.Parent.ChasingSomeone.Value == true then
	
abilityrandomiser = math.random(1)

print(abilityrandomiser)

	if abilityrandomiser == 1 then
		AttemptM1()
		end
	end
end

A little bit more explanation about the code:
there is a hitbox around the dummy and if the player enters it then the dummy is allowed to attack, however if they exit it the dummy is not allowed to attack.
as the while loop, the only reason there is a randomiser to begin the function to play the animation is because i am going to have multiple abilities.
all the code seems to work, i think (hope) its mostly an animation problem.

Ps:
Would be really nice if i got some help on this, ive never encountered a situation as stupid as this…
Thanks.

1 Like

Have you tried changing the priority of the animation from the animation editor?
Otherwise you can also do it by code:

local M1AnimTrack = selfhumanoid:LoadAnimation(M1Animation)
M1AnimTrack.Priority = Enum.AnimationPriority.Action
M1AnimTrack:Play()
2 Likes

I set it from the animation and it worked, im so stupid, I usually always remember to set the priority but apparently not this time :sweat_smile:.
Thank you for the help though!

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