AnimationClipProvider error

I’m experiencing a AnimationClipProvider Error, and I don’t know what’s causing it
image
I’m trying to make a tool with a viewmodel flashlight, but the thing is the line of code is important for animating

wait()
local Player = game.Players.LocalPlayer
local tool = Player.Character:FindFirstChild("Flashlight") or Player.Backpack:FindFirstChild("Flashlight")
local char = Player.Character
local ViewModel = game.ReplicatedFirst.FlashlightVm:Clone()
local humanoid = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
local Camera = workspace.Camera
local run = game:GetService("RunService")
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera



local mult = 3
local swayOffset = CFrame.new()
local lastCameraCF = workspace.CurrentCamera.CFrame

local function renderloop()
	local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF)
	local x,y,z = rotation:ToOrientation()
	swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult,0), 0.1)
	ViewModel.HumanoidRootPart.CFrame = ViewModel.HumanoidRootPart.CFrame * swayOffset
	lastCameraCF = workspace.CurrentCamera.CFrame
end

local IdleAnim = ViewModel.Idle
local WalkAnim = ViewModel.Walk
local EquipAnim = ViewModel.Equip

local animController = ViewModel.AnimationController
local animator = animController.Animator

tool.Equipped:Connect(function()
	run.RenderStepped:Connect(function()
		ViewModel:SetPrimaryPartCFrame(Camera.CFrame * CFrame.new(0,0,0))
		renderloop()
	end)
	local IdleAnimationTrack = animator:LoadAnimation(IdleAnim)
	local WalkAnimationTrack = animator:LoadAnimation(WalkAnim)
	local EquipAnimationTrack = animator:LoadAnimation(EquipAnim)
	EquipAnimationTrack:Play()
	IdleAnimationTrack:Play()
end)

This is the code, the line with the error is local IdleAnimationTrack = animator:LoadAnimation(IdleAnim), same goes with the others, anyone know what causes it?

2 Likes

sorry for replying that late,
but i tried making something like this

i have no idea how to reply here

local tool = script.Parent

local plr = nil
local char = nil
local hum = nil

tool.Equipped:Connect(function()
char = tool.Parent
if game:GetService("Players"):GetPlayerFromCharacter(char) ~= nil then
plr = game:GetService("Players"):GetPlayerFromCharacter(char)
if char:FindFirstChildOfClass("Humanoid") then
hum = char:FindFirstChildOfClass("Humanoid")
end
end)

then you could add some kind of check if the script got humanoid and etc
i had the same error, and these lines of code helped me, hope they will help you as well

1 Like

thanks!

asdasdsdaasdasdwedadaw

1 Like