I need help on scripting my tool. So I want my tool to animate when i press a hotkey since I wanted to have a various animations on my tool.
First of all, you're going to create a function which fires when you press a hotkey.
local keyToPress = "e" -- This is the hotkey. game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)) if string.lower(key) == keyToPress then print("You just pressed the E hotkey!") end end
Now we're going to make that function play an animation using this.
local keyToPress = "e" -- This is the hotkey. local animation = script.Animation -- You're gonna have to edit that. animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(animation) game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)) if string.lower(key) == keyToPress then animTrack:play() end end