Log in to vote
0

[ANSWERED] I made a script with UserInputService. Why isn't this working?

Asked by 3 days ago
Edited 3 days ago

I am working on a simple run script, and using UserInputService to detect when the player presses LeftShift.

Code:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.KeyCode.LeftShift then
        print("the player pressed shift!")
    end
end

But, when I press LeftShift, I don't get anything in the output. So, if you have time, please help me out!

Thanks in advance!

(I put the code in a LocalScript inside of StarterGui)

0
Try using this: AugustusDaGloop 0 — 3d
0
On line 04, it should be input.KeyCode, not input.UserInputType. Also, I don't think scripts in StarterGui replicate, trying putting it in StarterCharacterScripts. radiant_Light203 1050 — 3d
0
scripts do replicate to the clients in startergui. But radiant is correct that it should be input.Keycode. JustinWe12 130 — 3d
0
I did what radiant_Light203 and JustinWel12 said to do and it worked. Thanks! andarwniceguyjr 0 — 3d

Answer this question