I'm trying to to play a animation when I click with the tool equipped but this error keeps showing up. Here's my script:

local player = game:GetService("Players").LocalPlayer
local character = player.Character
local Throw1 = script.Parent:FindFirstChild("Throw1")
local PlayA = character.Humanoid:LoadAnimation(Throw1)
local CanThrow = true
local dobounce = 1


script.Parent:Activated():Connect(function()
	if CanThrow then
		CanThrow = false
		PlayA:Play()
		wait (dobounce)
		CanThrow = true
	end
end)

2 comments

0

Instead of using FindFirstChild("Throw1") on line 03 use WaitForChild("Throw1", 10) so that it waits until it finds the animation before trying to load it to the humanoid, which is probably what is causing the problem.

0

Instead of using FindFirstChild("Throw1") on line 03 use WaitForChild("Throw1", 10) so that it waits until it finds the animation before trying to load it to the humanoid, which is probably what is causing the problem.