So i was making an Sprint script by holding shift and i got this problem
local UIS = game:GetService("UserInputService") local player = game.Players.LocalPlayer UIS.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.Keyboard.Shift then print("SHIFTttt") end end)
I has the error Shift is not valid member
How did i do wrong? Tell me please
Useless i was trying with right - left shift thingy
Shift is a part of KeyCode and you are using UserInputType which does not have a child called Shift which explain the error in this code ie There is nothing called Shift under Kyeboard.
The other issue is that you should be checking the KeyCode for the pressed key and include left of right shift
Example
local UIS = game:GetService("UserInputService") local player = game:GetService("Players").LocalPlayer UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.LeftShift then print("Left shift down") end end)
Hope this helps
It's because Shift isn't a valid member of Keyboard, as the error says. Keyboard is used whenever a keyboard button is pressed. Instead you'd use KeyCode, then LeftShift or RightShift.
local UIS = game:GetService("UserInputService") local player = game.Players.LocalPlayer UIS.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.LeftShift then print("SHIFTttt") end end)