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

bruh this is so dum and ugh?

local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input,GPE)
	if not GPE then
		if Input.KeyCode == Enum.KeyCode.Q then

it shows a error that the input object has no keycode? wtf.

2 comments

0

if u want the full script i could post it

0

put the full script its the only way

2 answers

✓ Accepted answer

try this and tell me if it works

local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input,GPE)
    if not GPE then
        if Input.UserInputType == Enum.UserInputType.Keyboard then
		if Input.KeyCode == Enum.KeyCode.Q then

1 comment

0

sorry for ur trouble i managed to figure it myself but thanks for trying to help anyway

if you're not trying to make anything too advanced, i would recommend using ContextActionService, it's a bit more simple, and your keycode won't run if you're typing in chat.

example:

local CAS = game:GetService("ContextActionService")

local function Button(actionName, inputState, inputObj)
	if inputState == Enum.UserInputState.Begin then --this will make the code only run when you press it down, so it doesn't fire twice.
	print("hi")
	end
end

--CAS:BindAction  must always be below the function in order to work

CAS:BindAction("any name here", Button, true, "q")

--the parameters needs the following in order:

--string name
--the name of the function you want it to bind
--create a button for mobile players
--key you want to bind

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