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

Why won't it print when I hit a, am I not referencing it correctly?

UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProccesedEvent)
	if input.KeyCode == Enum.KeyCode.A then
		print("YO DAWG COME SEE DIS HE PRESSIN DA A KEY!!")
	end
end)

4 comments

0

When I tried using gameProcessedEvent it didnt worked too, tr just ignoring that parameter. . .

0

is it a LocalScript? it won't work on a ServerScript.

0

it is a local script

0

is it in the staterplayer-starterplayerscripts folder?

1 answer

✓ Accepted answer

There is no problem in your script, it works properly. But if it doesn't print what you want, then check if your script is a LocalScript and is located in StarterGui. If it still does not work, type this code inside of your script:

UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.A then
		print("YO DAWG COME SEE DIS HE PRESSIN DA A KEY!!")
	end
end)

And if it still does not, try this:

local keyDown = false

UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, GPE)
	if input.KeyCode == Enum.KeyCode.A then
		keyDown = true
		print("YO DAWG COME SEE DIS HE PRESSIN DA A KEY!!")
	end
end)

If even that doesn't work, try contacting Roblox staff about the problem, but there should not be any problems.

2 comments

0

yeah for some reason it started working idk what was wrong before, but thanks!

0

Happy to help :))

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