Iv done it before and have the same thing. All the sudden it doesnt work. i tried many things. but the two mains things were this code
UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.M then
print("hi")
--print(Input.Name)
--print(Input.Parent.Name)
end
end)
and i tried it in a normal script and local script. both in workspace. also tried putting both in starterpack. it does not print hi when i press m in testing mode. please help

2 comments
You can only capture the input of the player in the client, I suggest you check a question I answered about where you can place your LocalScripts so your code works. https://scriptinghelpers.org/questions/55070/whats-the-best-place-to-store-local-scripts#53918
OH MY ###### PIECE OF ## THIS WORKS, I PUT IT IN STARTER PLAYERSCRIPTS AND IT WORKS.