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

How to solve UserInputService?

I was running a simple piece of code and i came upon a error, outputs not giving me anything

local UserInputService = game:GetService("UserInputService")

local aKeyPressed = false

UserInputService.InputBegan:Connect(function(input, gameProccesed)
	if input.KeyCode == Enum.KeyCode.A then
		aKeyPressed = true
		
		while aKeyPressed == true do
			wait()
			print("A Key is being held")
		end
	end
end)

UserInputService.InputEnded:Connect(function(input, gameProccesed)
	if input.KeyCode == Enum.KeyCode.A then
		aKeyPressed = false
	end
end)




1 answer

✓ Accepted answer

It's not

if UserInputService == Enum.KeyCode.A then

its the parameter you use, which in this case is "input" EDIT: forgot to put ".KeyCode"

if input .KeyCode== Enum.KeyCode.A then

7 comments

0

still doesnt work

0

Sorry i forgot the ".KeyCode" I have edited it

0

how do you edit it

0

theres an edit button..

0

i just realised it wasnt in a local script

0

Bruh

0

my bad

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