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

Pressing E Doesn't Trigger Animation?

So, I have a script requiring UserInputService to trigger an animation when the key E is pressed. Although UserInputService is working fine, I checked, it works just fine, the trigger for E is not working correctly. The Output gives me 0 errors which confuses me even more- Here's my code.

local input = game:GetService("UserInputService")
function onInput(process,plrinput)
   			 if not process then --Make sure player isn't typing in chat
       		 if plrinput.KeyCode == Enum.KeyCode.E then --Check key
			
			local animation = Instance.new("Animation")
			animation.AnimationId = "http://www.roblox.com/Asset?ID=<insert animation here>"

 		      end
  			  end
end
 
input.InputBegan:Connect(onInput)


I might be a fool for not knowing how to do this, but uh... Hey, at least I asked.

3 comments

0

Did you load the animation into the humanoid?

0

...Uh... Y-YEAH! I DID! Hahahahahaha. Wow, I sure am smart!

0

m

3 answers

  1. Put the animation In workspace
  2. Make sure you are the creator of the animation ID
  3. Visit ROBLOX wiki

I think you switched the process and player input.

1 comment

0

the key goes first

Hey OrcaTheFish,

You are so close to getting it correct, it's just that you switched the parameters around. The first parameter in that function is the Object that is pressed down and the second one is the game processed event to check if the key was pressed while typing or not. All you have to do is in the first if statement, replace process with plrinput and in the second if statement, replace plrinput with process.

#Well, I hope I helped you out in some way and here is the wiki page for UserInputService if you would like to know how this works.

~~ KingLoneCat

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