-
What do you want to achieve?
I want to instantly play a new Idle animation after changing the animationid
Problem?
After changing the idle animation id the old idle animation is still playing until you move or jump.
As you can see, the new animation only plays after you move.
I am guessing that the new idle animation doesnt play because of humanoidstatetype not changing?
What solutions have you tried so far?
I have tried searching on the Developer Hub but the only topic that came up was "Detect if player change animation"
Code (Server Script)
game.ReplicatedStorage.WeoponEquipEvent.OnServerEvent:Connect(function(Player, Character, WeoponName)
local IdleOne = Character.Animate.idle.Animation1
local IdleTwo = Character.Animate.idle.Animation2
local Walk = Character.Animate.run.RunAnim
local Jump = Character.Animate.jump.JumpAnim
local Fall = Character.Animate.fall.FallAnim
local Weopon = game.ReplicatedStorage.WeoponModels:FindFirstChild(WeoponName):Clone()
Weopon.Parent = Character
local Motor6D = Instance.new("Motor6D")
Motor6D.Parent = Character:FindFirstChild("HumanoidRootPart")
Motor6D.Name = "WeoponMotor6D"
Motor6D.Part0 = Character:FindFirstChild("HumanoidRootPart")
Motor6D.Part1 = Weopon.PrimaryPart
IdleOne.AnimationId = Weopon:FindFirstChild("Idle").AnimationId
IdleTwo.AnimationId = Weopon:FindFirstChild("Idle").AnimationId
Walk.AnimationId = Weopon:FindFirstChild("Walk").AnimationId
Jump.AnimationId = Weopon:FindFirstChild("Jump").AnimationId
Fall.AnimationId = Weopon:FindFirstChild("Fall").AnimationId
local EquipAnimation = Instance.new("Animation")
EquipAnimation.AnimationId = Weopon.Equip.AnimationId
Character.Humanoid:LoadAnimation(EquipAnimation):Play()
end)