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

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

Asked by 3 years ago
Edited 3 years 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 — 3y
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 1166 — 3y
0
scripts do replicate to the clients in startergui. But radiant is correct that it should be input.Keycode. JustinWe12 723 — 3y
0
I did what radiant_Light203 and JustinWel12 said to do and it worked. Thanks! andarwniceguyjr 0 — 3y

Answer this question