Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Animation on KeyDown?

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

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()"

6 comments

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?

0

At the end of line four, its cut off, the ":Play" part, change it to ":Play()"

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?

0

by the way it says that there should be an end to end the if statement at line 3

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

0

k, I give up!

my guess is to do

OnKeyDown(e) do function
play.Animation()

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

This discussion is preserved as it was. New answers, comments, and votes are closed.