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

Animation on KeyDown?

Asked by 10 years ago

I would like to know how to make animations play OnKeyDown. You know you feell like doing something or whatsoever... well anyway, thanks for listening.

2 answers

Log in to vote
1
Answered by
Hybric 271 Moderation Voter
10 years ago

Put the Animation Into StarterPack.
Name the Animation: hybric
Insert a Local Script into StarterPack. Make the LocalScript have this:

function Hybric(key)
local key = key:lower()
if key == "e" then -- change "e" to the Key you want it to be
script.Parent.Parent.Character.Humanoid:LoadAnimation(script.Parent.hybric):Play() -- hybric is the animation name, if you didnt put that as the name, change it to "hybric"
end
end

script.Parent.Parent:GetMouse().KeyDown:connect(Hybric)

> LOOK AT LINE 4, ITS CUT OFF, THE ":PLAY(" SHOULD BE ":Play()"

0
thnx :D I'll check it out... btw, would there be a possibility to play sounds with the animation? and also, you said "hybric" do you still have to put the () at the end? kapitanovaskapandr 0 — 10y
0
At the end of line four, its cut off, the ":Play" part, change it to ":Play()" Hybric 271 — 10y
0
I did... but nothing is working :( I checked the output though... it said "failed to load roblox.com/asset/id?[and then the code] could you help me with this problem? kapitanovaskapandr 0 — 10y
0
by the way it says that there should be an end to end the if statement at line 3 kapitanovaskapandr 0 — 10y
View all comments (2 more)
0
16:59:08.148 - KeyDown is not a valid member of Backpack 16:59:08.149 - Script 'Players.Player1.Backpack.LocalScript', Line 8 16:59:08.149 - stack end kapitanovaskapandr 0 — 10y
0
k, I give up! kapitanovaskapandr 0 — 10y
Ad
Log in to vote
1
Answered by 10 years ago

my guess is to do

OnKeyDown(e) do function
play.Animation()

something like that but that wouldn't work am sure of it.

Answer this question