How to add an idle animation to a non moving npc?

Does anyone know how to add an idle animation to a non moving npc? I am using Moon Animator and no tutorials helped because I cant figure out how to get an animation id. I am just using an exported animation from Moon Animator.

Wait so…you’ve got the keyframe thing that was exported from moon animator, and you want to get the animation id?

Yeah, basically I want to get the animation id.

I found this on the developer hub

    local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
    
    local function createPreviewAnimation(keyframeSequence)
    	local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence) 
    	if hashId then 
    		local Animation = Instance.new("Animation")
    		Animation.AnimationId = hashId
    		return Animation
    	end
    end

That way, you can do something like this to make the NPC play the idle animation.

    local humanoid = script.Parent.Humanoid --humanoid here
    local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
    
    local function createPreviewAnimation(keyframeSequence)
    	local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence) 
    	if hashId then 
    		local Animation = Instance.new("Animation")
    		Animation.AnimationId = hashId
            humanoid:LoadAnimation(hashId):Play()
    		return Animation
    	end
    end

createPriviewAnimation(script.Parent.Keyframe) --keyframe

ALTERNATIVELY, you can export the keyframe sequence by right clicking on it and selecting “Save to Roblox”, the animation saving prompt will appear and you can save your animation from there. This is the easiest way to do it

do this

Do you know what I should do once I get the animation ID?

You can create an animation and set the animation ID value of the animation to your animation ID, then you can have the humanoid to load the animation and play them.

make sure the animation is looped
put this in a script inside the npc

local dummy = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://animidhere"
animation.Parent = dummy
local anim = dummy:WaitForChild("Humanoid"):LoadAnimation(animation)
anim:Play()