Script Help: LoadAnimation requires an Animation object

  1. So I made a weapon giver like you would usually see in a tycoon. And I have a knife for the first weapon and I made the animations and the damage.

  2. Problem is, when I clone the tool from the serverstorage the animation doesnt work anymore and it gives me the error [LoadAnimation requires an Animation object]

  3. What solutions have you tried so far? Ive tried loading the character in a different way, such as "local char = player.Character or player.CharacterAdded:Wait()

local id = 10528074307
local canSlash = true
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local animation = script.Parent:FindFirstChild("Animation")


script.Parent.Activated:Connect(function()
	local swingAnimation = char.Humanoid:LoadAnimation(animation)
	if canSlash == true then
		swingAnimation:Play()
		canSlash = false
		wait(1)
		canSlash = true
	end
end)

Also extra info: The knife animation works if I pick up the tool from the ground or put it in the starterpack. Just not when its cloned into the backpack.

Make sure your variable animation isn’t nil. FindFirstChild will return an object if it finds the Animation or nil if it doesn’t, thus not giving an error. You could try WaitForChild instead.

So simple yet so helpful tysm !

1 Like