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

Pressing E Doesn't Trigger Animation?

Asked by 7 years ago
Edited 7 years ago

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.

0
Did you load the animation into the humanoid? V_ChampionSSR 247 — 7y
0
...Uh... Y-YEAH! I DID! Hahahahahaha. Wow, I sure am smart! OrcaTheFish 95 — 7y
0
m Gamersofthegodss 11 — 7y

3 answers

Log in to vote
0
Answered by
Admin8483 -21
7 years ago
  1. Put the animation In workspace
  2. Make sure you are the creator of the animation ID
  3. Visit ROBLOX wiki
Ad
Log in to vote
0
Answered by 7 years ago

I think you switched the process and player input.

0
the key goes first QuantumToast 261 — 7y
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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

Answer this question