I was trying to play an animation using the UserInputService. Does anyone know why this might not work? It prints fine, just doesn’t play the animation. No Errors in the output.
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = humanoid:LoadAnimation(script.Parent.Animation)
UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then
return
elseif input.KeyCode == Enum.KeyCode.E then
print("yo")
animation:Play()
end
end)
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = humanoid:LoadAnimation(script.Parent.Animation)
print("Character found")
UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then
return
elseif input.KeyCode == Enum.KeyCode.E then
print("yo")
animation:Play()
end
end)