How do I make an Animation out of a KeyFrameSequence?

I’ve read that you can create a temporary animation with it (Code:

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

)
But that doesn’t really work for me (Animation failed to load in). Is there an alternative to that?
I haven’t really worked with KeyFrameSequences yet. Thanks!

Maybe it gives me that error because I just copied the HashId and put it in an Animation?

Maybe it is to cause you dint any Id.

Maybe not but evrey animation has a Id.