local UserInputService = game:GetService("UserInputService")
local Animation = script.Animation
UserInputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Z then
local character = game.Players.LocalPlayer.Character
local Humanoid = character:WaitForChild("Humanoid")
local Anim = Humanoid:LoadAnimation(Animation)
local character = game.Players.LocalPlayer.Character
local Humanoid = character.Humanoid
local Anim = Humanoid:LoadAnimation(Animation)
Anim:Play()
end
end)
That is my script.
This is what it looks like in the animation editor
local UserInputService = game:GetService("UserInputService")
local Animation = script.Animation
UserInputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Z then
local character = game.Players.LocalPlayer.Character
local Humanoid = character:WaitForChild("Humanoid")
local Anim = Humanoid:LoadAnimation(Animation)
Anim.Priority = Enum.AnimationPriority.Action4 --Action4 is highest priority
Anim:Play()
end
end)