Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I trigger a Animation using keydown ?

Asked by 10 years ago

Hello, i've recently created an animation and i'm trying to learn how to trigger it in game using keydown. I have already tried this :

animation = Instance.new("Wide Reciever Stance")
animation.AnimationId. = "http://www.roblox.com/WR-Stance-item?id=173047536"

player = game.Players.LocalPlayer
mouse = player:GetMouse()

animTrack = nil
canPlay = true

mouse.keyDown:connect(function(activate)
activate = activate:lower()
if activate == "y" then
    if canPlay then
        canplay = false
        animTrack = player.Character.Humanoid:LoadAnimation(animation)
        animTrack.KeyframeReached:connect(function(keyframeName)
            keyframesReached = keyframesReached + 1
print("Keyframe #"..keyframesReached..": "..keyframeName)
canPlay = true
end)
end
animTrack:Play()
end 
end)


        end)
    end
end
end)

But it did not work. I am new to scripting. I'm not even sure if I'm doing this right.

0
Please put all your code in a code block (the blue Lua symbol) and tab it correctly. Perci1 4988 — 10y
0
"keyframesReached" is never defined prior to your event handler. NoahWillCode 370 — 10y

Answer this question