UserInputService's InputBegan event is not working at all

Whenever I use UserInputService’s InputBegan event it won’t work so why does that happen?

Here’s the script I’m using to test this:

Script
userinputservice.InputBegan:Connect(function(input, gameprocessedEvent)
    print("test") -- This doesn't work
end)
1 Like

Make sure it’s a localscript and it’s located in somewhere like StarterPlayerScripts or StarterGui.

Run takes perspective of the server so if you are sending input through run and the code is located in a server script then that’s your issue.

5 Likes

The service literally defines what it means: It detects whatever input a player makes (Inside a LocalScript, that is)

--Server Script
local Input = game:GetService("UserInputService")
Input.InputBegan:Connect(function(input, gameprocessedEvent)
print("test") -- This doesn't work 
end)

This code will only run once as Behind said, while this:

--Local Script inside a StarterPack
local Input = game:GetService("UserInputService")
Input.InputBegan:Connect(function(input, gameprocessedEvent)
print("test") -- This doesn't work
end)

Will run and detect whenever a player inputs a certain action

1 Like

It won’t even run once, actually.

The second one works, yes? I think you forgot to remove that comment.

1 Like

I quite didn’t understand what you meant to say