Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago
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)

0
When I tried using gameProcessedEvent it didnt worked too, tr just ignoring that parameter. . . Necro_las 412 — 4y
0
is it a LocalScript? it won't work on a ServerScript. Mayk728 855 — 4y
0
it is a local script MOREHOURSOFFUN 104 — 4y
0
is it in the staterplayer-starterplayerscripts folder? Barty200 85 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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.

0
yeah for some reason it started working idk what was wrong before, but thanks! MOREHOURSOFFUN 104 — 4y
0
Happy to help :)) DangerousKillerTimur 54 — 4y
Ad

Answer this question