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

How to solve UserInputService?

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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
0
still doesnt work 4KChanxxe 4 — 3y
0
Sorry i forgot the ".KeyCode" I have edited it smidgesrev 54 — 3y
0
how do you edit it 4KChanxxe 4 — 3y
0
theres an edit button.. smidgesrev 54 — 3y
View all comments (3 more)
0
i just realised it wasnt in a local script 4KChanxxe 4 — 3y
0
Bruh smidgesrev 54 — 3y
0
my bad 4KChanxxe 4 — 3y
Ad

Answer this question