Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Argument 1 missing or nil on my Animation? (slideAnimation:Play())

Asked by 2 years ago

I've been writing a slide script and I have never seen this error before, so I dont even know what to do, i've searched on the internet but all the other posts dont relate to what I am looking for

Script:

local UIS = game:GetService("UserInputService")
local charactor = script.Parent
local slideAnimation = Instance.new("Animation")
local Humanoid = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")
slideAnimation.AnimationId = "https://www.roblox.com/assets/?id=7304632601"

local SlideKey = Enum.KeyCode.LeftControl

local CanSlide = true

UIS.InputBegan:Connect(function(input,gameprocessed)
    if gameprocessed then return end
    if not CanSlide then return end

    if input.KeyCode == SlideKey then
        CanSlide = false

        local playAnimation = charactor.Humanoid:LoadAnimation(slideAnimation)
-- THE ERROR IS HERE
        slideAnimation:Play()

        local slide = Instance.new("BodyVelocity")
        slide.MaxForce = Vector3.new(1,0,1) * 30000
        slide.Velocity = charactor.HumanoidRootPart.CFrame.lookVector * 100
        slide.Parent = charactor.HumanoidRootPart

        for counts = 1, 50 do 
            wait(.1)
            slide.Velocity *= .7
        end
        playAnimation:Stop()
        slide:Destroy()
        CanSlide = true

    end
end)



Before getting this error, I noticed there was an "end" that was underlined with red, so I deleted it and no other erros appeared other than this.

any help is appreciated

1 answer

Log in to vote
1
Answered by 2 years ago

Instead of calling :Play on the animation instance itself, you should call :Play() on the loaded animation (aka playAnimation).

You should also call it on the animator instead of the humanoid, since it is deprecated.

So it should look something like this

local slideAnimationTrack = character.Humanoid.Animator:LoadAnimation(slideAnimation)
slideAnimationTrack:Play()
Ad

Answer this question