So I’m making a script that if you touch a button it will play an animation but everytime the player dies it comes up with this error.
Cannot load the AnimationClipProvider Service
The script is
local player = game.Players.LocalPlayer
local Character = player.Character
local Hold = false
local Cooldown = false
local Time = 3 --Example time
script.Parent.MouseButton1Click:Connect(function()
if Cooldown == false then
Character.Humanoid:LoadAnimation(script.Throw):Play() --Error
Hold = false
Cooldown = true
wait(cooldownTime)
Cooldown = false
Time = 0
repeat wait() until not Hold
end
end)
I am not an expert on this service or anything but maybe try using the animation inside of an animation controller instead of the script.
Maybe try:
local player = game.Players.LocalPlayer
local Character = player.Character
local AnimationController = Character:WaitForChild("AnimationController")
local Hold = false
local Cooldown = false
local cooldownTime = 3
script.Parent.MouseButton1Click:Connect(function()
if Cooldown == false then
local animation = AnimationController:LoadAnimation(script.Throw)
animation:Play()
Hold = false
Cooldown = true
wait(cooldownTime)
Cooldown = false
Time = 0
repeat wait() until not Hold
end
end)
And also make sure that you have the animation set up inside of the animation controller.
You may be getting this error because ‘Character’ is undefined.
When starting up the game, the player’s character isn’t instantly loaded in. Simply getting the player’s character on startup causes issues.
There are two fixes you can do:
The first way is to change
local Character = player.Character
Into
local character = player.Character or Player.CharacterAdded:Wait()
This will halt the script until the character is loaded.
Another option would be to define the character every time the function is ran. This is good for cases where the character dies and the script does not reset.