Here is my code. Assets is a folder with animations, particle effects, sounds and models.
local anim2 = humanoid:LoadAnimation(assets.animation)
anim2:Play()
local character = script.Parent
local humanoid = character.Humanoid
local humanoidRootPart = character.HumanoidRootPart
local head = character.Head
local player = game.Players:GetPlayerFromCharacter(character)
local rightArm = character["Right Arm"]
This script is parented to the character once it spawns. Animation priority is ACTION and there is nothing else with the animation priority ACTION.
local anim2 = humanoid:LoadAnimation(assets.animation)
local character = script.Parent
local humanoid = character.Humanoid
local humanoidRootPart = character.HumanoidRootPart
local head = character.Head
local player = game.Players:GetPlayerFromCharacter(character)
local rightArm = character["Right Arm"]
anim2:Play()
What is the difference between the scripts?
You can’t put the animation before declaring the humanoid.
local anim2 = [**humanoid**]:LoadAnimation(assets.animation)
anim2:Play()
local character = script.Parent
local [**humanoid**] = character.Humanoid
local humanoidRootPart = character.HumanoidRootPart
local head = character.Head
local player = game.Players:GetPlayerFromCharacter(character)
local rightArm = character["Right Arm"]
you should also use animator as humanoid:LoadAnimation is Deprecated
local character = script.Parent
local humanoid = character.Humanoid
local Animator = Instance.new("Animator")
Animator.Parent = humanoid
local anim2 = Animator:LoadAnimation(assets:WaitForChild("animation")
anim2:Play()