How Do I fix this error? -- Cannot load the AnimationClipProvider Service

Everything in the script is Fine…
Until I die then I get this error I’m very new to scripting and this is my first Dev Forum post so feedback to make this clearer will be helpful

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local Frame = player.PlayerGui.EatFruitGui.Main
local Yes = Frame.Yes
local No = Frame.No

local EatAnim = script:WaitForChild("Eat")
local EatAnimTrack = humanoid.Animator:LoadAnimation(EatAnim)

local DevilFruits = game.ReplicatedStorage.DevilFruits
local currentTool = script.Parent
local Toolname = "Rubber"




local function boop(Player)
	Frame.Visible = true 
	local character = currentTool.Parent
	local playerWhoEquippedTool = game.Players:GetPlayerFromCharacter(character)
	Yes.MouseButton1Click:wait()
		EatAnimTrack:Play()
		humanoid.WalkSpeed = 0
		wait(3.5)
		script.Parent:Destroy()
		if not playerWhoEquippedTool.Backpack:FindFirstChild(Toolname) then
			local Tool = game.ReplicatedStorage.DevilFruits[Toolname]:clone()
			Tool.Parent = playerWhoEquippedTool.Backpack
			humanoid.WalkSpeed = 16
	else
		No.MouseButton1Click:wait()
 end
end
currentTool.Activated:Connect(boop)

The error line is Line 10 Which is - local EatAnimTrack = humanoid.Animator:LoadAnimation(EatAnim)

So you get this error if the animation is being played while the player is dead. The easiest way to avoid this is to run a if statement to check if the player is dead. In your case that would look like:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)

local Frame = player.PlayerGui.EatFruitGui.Main
local Yes = Frame.Yes
local No = Frame.No

local EatAnim = script:WaitForChild(“Eat”)
local EatAnimTrack = humanoid.Animator:LoadAnimation(EatAnim)

local DevilFruits = game.ReplicatedStorage.DevilFruits
local currentTool = script.Parent
local Toolname = “Rubber”

local function boop(Player)

if player.Character.Humanoid.Health > 0 then

Frame.Visible = true 
local character = currentTool.Parent
local playerWhoEquippedTool = game.Players:GetPlayerFromCharacter(character)
Yes.MouseButton1Click:wait()
	EatAnimTrack:Play()
	humanoid.WalkSpeed = 0
	wait(3.5)
	script.Parent:Destroy()
	if not playerWhoEquippedTool.Backpack:FindFirstChild(Toolname) then
		local Tool = game.ReplicatedStorage.DevilFruits[Toolname]:clone()
		Tool.Parent = playerWhoEquippedTool.Backpack
		humanoid.WalkSpeed = 16
else
	No.MouseButton1Click:wait()

end
end
end
currentTool.Activated:Connect(boop)

I still get the error even with this code? also the error is higher up at line 10 should i put the if statment higher up or?

YES IVE FOUND IT, i just had to put repeat task.wait() until Player.Character under local player = … thank god

1 Like