Play is not a valid member of Animation "Animation"?

In this script I am trying to make my character slide, however on activation of the script, it keeps saying "Play is not a valid member of Animation “Animation”, and I dont know how to fix it. I’ve looked across the internet but none of the other posts seem to be similar to mine. Any help is appreciated

The 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 PROBLEM LINE
		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)


If anyone can help me with this it will be greatly appreciated

1 Like

the animator loads animations, not the humanoid

local playAnimation = charactor.Humanoid.Animator:LoadAnimation(slideAnimation)
-- THE PROBLEM LINE
slideAnimation:Play()
2 Likes

Alright, so I changed it to your suggestion (it worked) but it is not playing the animation.

example:

Gyazo link about the slide

I fixed the issue, turns out 1) i have to play the “playAnimation” and 2) the animation was glitched and didnt work

You need to play the track and not the animation.