Animation stopping early

I’m trying to make a silly creature peek around a corner and go away when you go close, but the animation is ending early resulting in the silly dubious creature disapearing earlier, witch looks a bit weird.
Video of what happens:

Code:

local hum = script.Parent:FindFirstChildOfClass("Humanoid")
local peekanim = hum:LoadAnimation(script:WaitForChild("Peek"))
local trigger = script:WaitForChild("Trigger")
peekanim.Looped = true
peekanim:Play()

local deb = false
trigger.Touched:Connect(function(hit)
	if deb == false then
		if game.Players:GetPlayerFromCharacter(hit.Parent) then
			deb = true
			trigger:Destroy()
			local walkawayanim = hum:LoadAnimation(script:WaitForChild("WalkAway"))
			walkawayanim:Play()
			walkawayanim.Ended:Wait()
			script.Parent.Parent = game.ServerStorage
		end
	end
end)

Anyone here to help? It’s been 9 hours.

Hello. Are you sure that your animation is longer than dissappearing time? It can be animation problem, not a script problem.

It seems like the issue might be with the animation itself, but there could be a simple workaround. You can try adding a number between the parentheses when playing the animation to smooth the animation weight, resulting in less harsh playbacks at the start.

For example, you can modify your code like this:

walkawayanim:Play(1)

This should help make the transition smoother.

Anyone still want to help? It’s been a whole week.

it’s roblox fault, its pretty much unfixable (i think), but if you do it in-game it’ll load a lil-bit properly, but you can preload the animation What is the best way to preload all assets?