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

I need help with KeyBinding Help?

Asked by
xTalzo 10
9 years ago

I need help with key binding. I have the anmations already set up. Like I want to throw a punch with the letter "E" How do I do that?

1 answer

Log in to vote
0
Answered by
drew1017 330 Moderation Voter
9 years ago

Once you want to start letting players do stuff interactively, you're going to want to get familiar with UserInputService. It can only be used from a localscript, so if you're using FE you'll need it to activate RemoteFunctions / Events, but otherwise its the simplest and smoothest key binding system you can get.

Heres some example code for a simple UserInputService function without FE:

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(input) -- Set up the function
    if input.KeyCode == Enum.KeyCode.E then -- checks if E was the pressed key
        -- do attack stuff
    end
end)

Which will cause the do attack stuff code to run when you press E.

Theres alot more to UIS than this, however. You can read up on it here.

Ad

Answer this question