Essentially what we’re doing is creating a new “Animator” for your character by calling Humanoid:LoadAnimation(), then in your Input function we call LoadedAnimation:Play() to play it.
local CoolDown = true
local Key = "Z"
local Animation = script.Animation
local Humanoid = Character:WaitForChild("Humanoid")
local LoadedAnimation = Humanoid:LoadAnimation(Animation)
-- do not put Animation in quotation marks, since it's a variable, not text
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] and CoolDown and Character then
CoolDown = false
LoadedAnimation:Play()
Remote:FireServer()
wait(5)
CoolDown = true
end
end)
Something like this should work, and as @NamyDev said be sure to put an Animation inside of your script, like this, then in “Properties” change the AnimationId to your id.
The default way to load Humanoid:LoadAnimation(), is deprecated. Animator is a child of the Humanoid and it’s a better alternative to load animation. So you should use Animator:LoadAnimation()