AnimationClipService error

I’ve recently made an idle animation and I’m trying to play it on the player’s cloned character

local RS = game:GetService("ReplicatedStorage")
local Tween = game:GetService("TweenService")
local Stance = RS:WaitForChild("Stance")
local FStance = Stance:WaitForChild("FireStance")

FStance.OnServerEvent:Connect(function(player, status)
	local character = game.Workspace:WaitForChild(player.Name) or player.Character or player.CharacterAdded:Wait()
	character.Archivable = true
	print(player.Name)
	if status == "Equipped" then
		task.wait(0.1)
		local PlayerStance = character:Clone()
		local AnimLoader = Stance.AnimController:Clone()
		PlayerStance.Name = "PlayerStance"
		AnimLoader.Parent = PlayerStance
		local PlayerStanceHumanoid = PlayerStance:FindFirstChild("Humanoid")
		local PlayIdle = PlayerStanceHumanoid:LoadAnimation(AnimLoader.Idle)
		PlayIdle:Play()
		for _, v in pairs(PlayerStance:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Part") then
				if v.Name ~= "HumanoidRootPart" then
				v.Transparency = 1
				local TweeningInfo = Tween:Create(v, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 0.66})
				TweeningInfo:Play()
				end
			end
		end
		PlayerStance.Parent = character
		PlayerStance.Animate:Destroy()
		PlayerStanceHumanoid.HumanoidDescription:Destroy()
		PlayerStanceHumanoid.Animator:Destroy()
		PlayerStanceHumanoid.DisplayDistanceType = "None"
		PlayerStance["Head"].face:Destroy()
		PlayerStance["Right Leg"]:Destroy()
		PlayerStance["Left Leg"]:Destroy()
		for _, v in pairs(PlayerStance:GetChildren()) do
			if v:IsA("BasePart") or v:IsA("Handle") or v:IsA("Part") then
				v.CanCollide = false
		    end
		end
		
		local welding = Instance.new("Weld", PlayerStance)
		welding.Name = "Welding"
		welding.Part0 = character.HumanoidRootPart
		welding.Part1 = PlayerStance.HumanoidRootPart
		welding.C1 = CFrame.new(0, 0, 0)
		
		local TweeningInfo = Tween:Create(welding, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {C1 = CFrame.new(2.7, -1.1, -2)})
		TweeningInfo:Play()
		
	elseif status == "Unequipped" then
		local PlayerStance = character:FindFirstChild("PlayerStance")
		local welding = PlayerStance:FindFirstChild("Welding")
		for _, v in pairs(PlayerStance:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Part")then
				if v.Name ~= "HumanoidRootPart" then
				local TweeningInfo = Tween:Create(v, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {Transparency = 1})
				TweeningInfo:Play()
				local TweeningInfo = Tween:Create(welding, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0), {C1 = CFrame.new(0, 0, 0)})
	            TweeningInfo:Play()
	            end
			end
		end
		wait(2)
		PlayerStance:Destroy()
	end
end)

but whenever I test the script, I get this error,

Any feedback on how to fix this issue would be appreciated, I was stuck on this issue for 2 hours and I’ve looked on the dev forum for solutions but I still had the same error…

Not sure if this is much help. But i did some testing and it seems that this error occurs when youre trying to load the animation onto something that has its parent set to nil(Nothing).

1 Like

So should I use task.wait and check if that fixes it?

You could give it a shot :slightly_smiling_face:


1 Like

The problem has been FIXED!!! All I needed to do was wait for the humanoid to load and replicate to the server before attempting to load an animation through it.

1 Like

Awesome!!!


1 Like

You should use WaitForChild to wait for the humanoid/animator to load/replicate before attempting to load an animation through it. Avoid using fixes like task.wait where possible.

1 Like

yeah, i also figured out that you needed to load the animation through the humanoid…