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

Animation on key down?

Asked by 9 years ago

Ive tried to create a onKeyDown play animation script but nothing works help??

0
Where the script at tho? This isn't a request site my friend. GreekGodOfMLG 244 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Put this in a LocalScript, then put your animation into the LocalScript: THIS IS CRUCIAL. Once your done put the LocalScript into StarterGui or StarterPack

01local Mouse = game.Players.LocalPlayer:GetMouse();
02 
03player = game.Players.LocalPlayer
04 
05animation = script:WaitForChild("Name of animation")
06 
07enabled = true
08 
09Mouse.KeyDown:connect(function(key)
10if (Key:lower() == "") then)   -- Put the key you want in between ""
11    if enabled then
12        enabled = false
13 
14        local animationTrack = player.Character.Humanoid:LoadAnimation(animation)
15        animationTrack:Play()
16 
17        wait(5-- How long you want it to take before you use it again.
18        enabled = true
19    end
20end)

I hope this helped, don't forget to accept the answer if it does. :)

0
P.S Join Xora Stduio :) kingstephen23 35 — 9y
Ad

Answer this question