UserInputService Not Working?

Hello i’m sorry for wasting anyones time again. but i can’t find a answer to my question anywhere else

I’m having some trouble figuring out why UserInputService is not detecting the input. i have tried trouble shooting the code, but it seems that it’s not even detecting that i am even pressing a key. I’m totally stumped why this doesn’t work, i really hope that this isn’t a simple answer otherwise i will feel really dumb.

Here is the code

local UIS = game:GetService("UserInputService")
local holding = true

UIS.InputBegan:Connect(function(input, isTyping)
	print("Detected The Button Press")
	if input.KeyCode == Enum.KeyCode.E then
		print("Detected The Input Was E")
		if isTyping then return else
			if holding == true then
				print("Detected That The Player Was Holding, And The Script Is Activated")
			end
		end
	end
end)

I have tried to look for answers online and even tried restarting roblox studio to see if this was a bug in the engine. I’m not getting any errors either. Any help would be appreciated alot.

1 Like

Is this in a serverscript or a localscript?

1 Like

This is a local script, More specifically in StarterCharcterScripts

Does it work if you put it in StarterPlayerScripts?

1 Like

No, it does not seem to work when i put it in StarterPlayerScripts

What does the console print when it’s in the startercharacterscripts?

1 Like

That’s the issue it prints nothing, nothing on StarterCharaterScripts or StarterPlayerScripts

Doubt this’ll work, but try it just in case.

local UIS = game:GetService("UserInputService")
local holding = true

UIS.InputBegan:Connect(function(input, isTyping)
    if isTyping then
        return
    end
	print("Detected The Button Press")
	if input.KeyCode == Enum.KeyCode.E then
		print("Detected The Input Was E")
	    if holding then
			print("Detected That The Player Was Holding, And The Script Is Activated")
		end
	end
end)
1 Like

When I pasted your script into a local script it worked perfectly fine.
Your script isn’t disabled or something right?

1 Like

add a bunch of print()s in between lines, and turn on lua debugger for all exceptions to find where the code stops executing or if it executed at all.

1 Like

No this did not work, unfortunatly

Literally could look at the code. :rofl:

1 Like


The Script isnt disabled

Strange. Are you receiving any errors from the output? Maybe try restarting Studio

1 Like

No i already tried restarting studio and, no errors appear.

again thats the problem i have already tried to do that, but it doesnt even detect that im pressing a key at all

Super weird.
For me it works fine.
Is the script inside your character when you test the game?

1 Like

Yeah, the script is in my character. still doesn’t work, the weird part is that it’s not producing any errors either

Try checking it it prints anything outside the event

1 Like

Is there another script that uses ContextActionService which binds the E key? Have you tried detecting any other key inputs being pressed?

1 Like