Animation is broken

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am creating a boss battle and I am curently doing dummy animations.(Spoiler: They don’t look good, they are just dummies, I will replace them with better animations once the game done)

  2. What is the issue? Include screenshots / videos if possible!
    Ehm, the animation isn’t playing in the way that I expected. Here a video showing the issue:

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find any solution because I don’t think that anyone has made an animation with the same issues that I have.

Let’s say what I am making: I am creating an temporary animation and play it. My motives is because the boss dosen’t hit the player, so the animation needs to adapt and I wanted to adapt it through code. My only solution is to create a Keyframe-sequence, change it and play the adapted animation, so that the hand hit the player.

The code may seems strange, I didn’t polished it, and it seems strange, but ignore everything, I will show the part that is relied to the animation:

Click to see (not recommanded, only if you are curious)
local function CheckAnimationPlaying(GolemAI, animationName)
	if GolemAI.AnimationHandler:IsAnimationPlaying(animationName) then GolemAI.AnimationHandler:Stop(animationName) end --If the golem is walking then stop the walking animation
end

local function GetInstanceByName(Array, Name)
	for _,instance in ipairs(Array) do
		if not (instance.Name == Name) then continue end
		return instance
	end
end

local function GetKeyframeFromSequence(Array, ID)
	if typeof(ID) == "number" then
		print("ID is a number")
		for _,keyFrame in ipairs(Array) do
			if not (keyFrame.Time == ID) then continue end
			return keyFrame
		end
	else
		return GetInstanceByName(Array, ID)
	end
end

function Attacks.ArmSwing(GolemAI, targetHumanoid)
	CheckAnimationPlaying(GolemAI, "Walking")

	local armSwingCompleted, debounce, targetHRP = false, false, targetHumanoid.Parent.HumanoidRootPart
	local Golem = GolemAI.Monster

	local keyframeSequence = game.ServerStorage.Game.Animations.Golem.KeyframeSequences.RightArmSwing

	local keyframe = GetKeyframeFromSequence(keyframeSequence:GetKeyframes(), "ArmSnap") do
		local Pose = keyframe.HumanoidRootPart.UpperTorso.UpperRightArm.LowerRightArm.RightHand
		Pose.CFrame = targetHRP.CFrame
	end

	local ArmParts = {Golem.UpperRightArm, Golem.LowerRightArm, Golem.RightHand}

	--This is the attack function. I created other topics asking to find a issue in my code and this is what I got. Credit to JedDevs, link below

	local maidClass = Maid.new()

	local function GolemnHit(hitPart)
		if armSwingCompleted then return end
		if not hitPart:IsDescendantOf(Golem) and hitPart.Parent:IsA("Model") then
			if not debounce and hitPart.Parent:FindFirstChild("Humanoid") then
				debounce = true
				targetHRP = hitPart.Parent.HumanoidRootPart
				hitPart.Parent.Humanoid:TakeDamage(10) 
				GolemAI.Humanoid:MoveTo(Golem.HumanoidRootPart.Position)
				armSwingCompleted = true
				maidClass:DoCleaning()
			end
		end
	end

	--The rest is created from me
	GolemAI.AttackUsed.Normal += 1

	local AnimationTrack = GolemAI.AnimationHandler:CreateAnimationFromSequence(keyframeSequence, GolemAI.Animator)
	AnimationTrack:Play()


	for _,Part in ipairs(ArmParts) do 
		maidClass:GiveTask(Part.Touched:Connect(GolemnHit))
	end
end

--The GolemAI.AnimationHandler (I am only showing the conserned function, nothing else)
function AnimationHandler:CreateAnimationFromSequence(keyframeSequence, Animator)
	local Asset = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence)
	
	local Animation = Instance.new("Animation")
	Animation.AnimationId = Asset
	
	return Animator:LoadAnimation(Animation)
end

Link: Unable to break loop + Touched Event isn't working - #8 by JedDevs

The animation part is here:

Click to see (actual problem, recommanded)
local keyframe = GetKeyframeFromSequence(keyframeSequence:GetKeyframes(), "ArmSnap") do --The keyframe is good, it's what I want to change
	local Pose = keyframe.HumanoidRootPart.UpperTorso.UpperRightArm.LowerRightArm.RightHand --This is the Pose. The Pose stores a CFrame that is where the part will move. I am modifying the target position of my hand in easier words.
	Pose.CFrame = targetHRP.CFrame*CFrame.Angles(Golem.RightHand.CFrame:ToEulerAnglesXYZ()) --And here is the changed Pose. Now, it should work, but it dosen't. Why?
end

--[...]

local AnimationTrack = GolemAI.AnimationHandler:CreateAnimationFromSequence(keyframeSequence, GolemAI.Animator) --Creating the Animation from the keyframe sequence. Read the wiki to learn more about keyframe sequences
AnimationTrack:Play() --And I am playing the animation

--[...]

--The GolemAI.AnimationHandler (I am only showing the conserned function, nothing else)
--This function 'CreateAnimationFromSequence'. It takes a KeyframeSequence with an Animator and returns a AnimationTrack. Again, I don't will explain these Instances, you should read the wiki to learn more about.
function AnimationHandler:CreateAnimationFromSequence(keyframeSequence, Animator)
	local Asset = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence) --Creates a temporary animationID, it's the same as a regular animationID, only temporary: No need to register it to Roblox, perfect to adapt an animation
	
	local Animation = Instance.new("Animation")
	Animation.AnimationId = Asset --Assign the temporary asset to the created animation
	
	return Animator:LoadAnimation(Animation)
end

I wrote comments that show what I am doing (only in the recommanded code snippet), now do anyone has an idea of what’s happening there? I am not getting any errors btw.