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

I need help with KeyBinding Help?

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

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.

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