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
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()