Animation ID not being created

I’m making an animation, but when uploading using the KeyframeSequenceRegistrator, only animation 2 is created and it says that animation 1 ID is empty. Here’s my code:

local part1KS = game:GetService("KeyframeSequenceProvider"):RegisterKeyframeSequence(game.Workspace.FirstAnimPart1)
local part2KS = game:GetService("KeyframeSequenceProvider"):RegisterKeyframeSequence(game.Workspace.FirstAnimPart2)
local anim1 = Instance.new("Animation")
anim1.Parent = game.Workspace
anim1.Name = "Animation1"
anim1.AnimationId = part1KS
local anim2 = Instance.new("Animation")
anim1.Parent = game.Workspace
anim1.Name = "Animation2"
anim1.AnimationId = part2KS
local animator = script.Parent.Humanoid:FindFirstChildOfClass("Animator")
if animator then
	local part1 = animator:LoadAnimation(anim1)
	local part2 = animator:LoadAnimation(anim2)
	part1:Play()
	part1.Stopped:wait()
	part2:Play()
end

Thanks for stopping by to help! Also the ID isn’t empty, I printed it out.

I think your script, when setting up anim2, should read like this, as it appears you’re still using anim1 for Animation2:

local anim2 = Instance.new("Animation")
anim2.Parent = game.Workspace
anim2.Name = "Animation2"
anim2.AnimationId = part2KS

I think that will fix it. The way it is now anim2.AnimationId will remain as nil - it’s not getting set.

Oh! I didn’t see this! Thanks for showing me this!

1 Like