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.
COMMUNITY QUESTION
How to animate tool on hotkey?
1 answer
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
This isn't a requesting forum, please try before you post or goto wiki.roblox.com for help