Answered by
4 years ago Edited 4 years ago
You have to load the animation first. Also, I'd use UserInputService
.
01 | local UserInputService = game:GetService( "UserInputService" ) |
03 | local anim = Instance.new( "Animation" ) |
05 | anim.Name = "TauntAnim" |
08 | local tool = script.Parent |
09 | local player = game.Players.LocalPlayer |
15 | UserInputService.InputBegan:Connect( function (input, gameProcessedEvent) |
16 | if not gameProcessedEvent and input.KeyCode = = Enum.KeyCode.E then |
17 | loadedAnim = player.Character.Humanoid:LoadAnimation(anim) |
22 | UserInputService.InputEnded:Connect( function (input, gameProcessedEvent) |
23 | if not gameProcessedEvent and input.KeyCode = = Enum.KeyCode.E then |
The InputBegan
event fires when an input begins (keyboard, mouse, etc.) Then there's an if statement checking if the player is not in chat, and if the input is "E" on their keyboard. Then the loadedAnimation plays. The InputEnded
is the same thing but it stops the animation.