Hi everyone. I’m having a very annoying issue right now. I’m trying to make an animation play whenever my NPC gets to a certain point. However, it doesn’t work correctly. Got anything that could help?
-
What do you want to achieve? Animation plays at the specified time.
-
What is the issue? Animation plays too early. See picture:
The green part is where the NPC starts. The red part isn’t important. The yellow part is where the animation should begin to play by the time the NPC touches it. -
What solutions have you tried so far? Changing the time, still plays too early.
Not exactly sure what to do here. Please help. Here’s the code I am using.
local Knight = script.Parent
Barbarian = nil
Finish = nil
Humanoid = nil
Enemy = nil
Animator = nil
EnemyAnimator = nil
if Knight ~= nil and Knight:FindFirstChild("Humanoid") and Knight:FindFirstChild("PathEnd") then
Humanoid = Knight.Humanoid
Finish = Knight.PathEnd
if Humanoid ~= nil and Finish ~= nil and Knight.Parent:FindFirstChild("Barbarian Staged (RIGHT)") and Humanoid:FindFirstChildOfClass("Animator") then
Animator = Humanoid.Animator
Barbarian = Knight.Parent["Barbarian Staged (RIGHT)"]
Humanoid:MoveTo(Finish.Position)
if Barbarian:FindFirstChild("HumanoidE") then
Enemy = Barbarian.HumanoidE
if Enemy ~= nil and Enemy:FindFirstChildOfClass("Animator") then
EnemyAnimator = Enemy.Animator
EnemyAnim = EnemyAnimator:LoadAnimation(Barbarian.Animation)
EnemyAnim.Priority = Enum.AnimationPriority.Action4
EnemyAnim:Play()
task.wait(3.18)
Anim = Animator:LoadAnimation(Knight.Animation)
Anim.Priority = Enum.AnimationPriority.Action4
Anim:Play()
task.wait(8.24)
end
end
end
end
After 3.18 seconds, that’s when the Knight’s animation plays, which is the amount of time it takes for the NPC to touch the part. However, it plays much earlier than that when the game is run. Any suggestions or tips?