"loadanimation requires an object"

this is the script, it says loadanimation requires an object

local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local debounce = false
local damage = 10
local animi = script.Parent.Punch
local anim = humanoid:LoadAnimation(animi)
local remotes = game:GetService("ReplicatedStorage"):WaitForChild("Remotes")
local punchevent = remotes:WaitForChild("Punch")

uis.InputBegan:Connect(function(input, gameProcessed)
    if input.KeyCode == Enum.KeyCode.F and not gameProcessed then
        if debounce == false then
            debounce = true
            local punchanim = humanoid:LoadAnimation(animi(character))
            punchevent:FireServer()
            wait(3)
            debounce = false
        end
    end
end)

You need an animation object in the argument

I’m not sure why you are giving animi(character) (most likely invalid) as the argument, this makes absolutely no sense

i know i do, but i dont know how to do it, this is why im asking here

what “object” does it need? im confused

It needs an object with the “Animation” class name, assuming that you have that object in animi, so try and do local punchanim = humanoid:LoadAnimation(animi)

it still wont work once i press f

Is script.Parent.Punch an Animation or another kind of Instance?

animation

Have you tried adding punchanim:Play() after loading? In addition, you should consider using AnimationController instead of directly putting into the Humanoid has Roblox has deprecated that method.

nope

20:56:12.371 LoadAnimation requires an Animation object - Client - Punch:15

It seems like script.Parent.Punch isn’t an Animation instance. Can you screenshot the instance? Have you tried printing it to see if it exists?

it isnt an instance. its an object

Well, an object is from an instance. You will let me help you or you will continue to experience the issue. Can you screenshot the instance (also know as the icon which tells the classification of the object)?

image

Replace script.Parent.Punch with script.Punch.

Issue: Solved

I LOVE YOU

(not in that way)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.