Here is my code:

local player = game.Players.LocalPlayer
local character = player.character or script.Parent
local humanoid = character.humanoid
local UserInputService = game:GetService("UserInputService")

local AnimationID = 'rbxassetid://5150687024'

local key = 'LeftControl'


UserInputService.InputBegan:Connect(function(Input, IsTyping)
	if IsTyping then return end
	if Input.KeyCode == Enum.KeyCode[key] then
		local animation = Instance.new("Animation")
		animation.AnimationID = AnimationID
		local loadAnimation = humanoid:loadAnimation(animation)
		loadAnimation:Play()
	end
end)

My problem is that I am attempting to keybind a sprint animation to Left Control, however it wont run in game. Please help if possible!

2 comments

0
  1. is it a local script? 2. if so, where is it located 3. any errors 4. why are u instancing a new animation object each time...
0

Under all circumstances, do not, take advice from the answer by @0kJu5tSp4ng3