I've been trying to figure out animations, and I figured out how to work them. I just can't figure out how to play them when you press a certain key. Help me please!
COMMUNITY QUESTION
How do you play an animation on keydown?
1 answer
I claim no credit This question has already been answered here: https://scriptinghelpers.org/questions/12609/animation-with-keydown-no-tool Look at other questions before you ask the same one. Either way they did this:
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?id=187720963"
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local animTrack = nil
Mouse.KeyDown:connect(function(key)
if key:lower() == "q" then
local character = Player.Character
animTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation)
animTrack:Play()
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
