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

How Can I Use Keybind Functions? [Solved]

So when a certain button on your keyboard is pressed I want it to run a certain script. In this case I am making a game where when you press a button on your keyboard it will run the script below it. I already have the script below it typed so all I need is the first line.

alert "CheckeredDev" + " is awesome but needs help scripting xD!";

5 comments

0

Your question is very vague.

1

That doesn't seem to make any difference except the fact of misunderstanding my conception

0

Yes and the point of you posting this here was so we could help you, we can't help you if we can't understand what your saying.

1

I'm saying is there a LINE OF CODE that can make it so it will run a script

0

No attempt has been made and code provided is in another language and doesn't solve the problem anyways.

1 answer

✓ Accepted answer

This might not be what you mean but here:

Make sure API services are enabled

local UserInputService = game:GetService("UserInputService")
local Key = 'Z' -- change 'Z' to the key you want to press
UserInputService.InputBegan:Connect(function(Input, IsTyping)
	if IsTyping then return end
	if Input.KeyCode == Enum.KeyCode[Key] then
		--script here
	end
end)

3 comments

0

API Services are enabled?

0

if API Services aren't enabled, your whole script won't work, so you gotta make sure it's enabled for your script to work. In case you don't know how to enable: ||||| 1: Go to the games page 2: click the little cog next to the game 3: click 'edit game' 4: enable API |||||

1

Yeah... I don't need to know how to turn on API services... I have been programming since 2015

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