this was my example code (tried to make some simple run script)
--RUNNING SCRIPT--
-------------------------------
local RunSpeed = 18
local NormalSpeed = 12
local SlowSpeed = 10
-------------------------------
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(Input, GameProcessedEvent)
print(Input.KeyCode)
--if not GameProcessedEvent then
if Input == Enum.KeyCode.LeftShift then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = RunSpeed
elseif Input == Enum.KeyCode.LeftControl then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = SlowSpeed
end
--end
end)
UIS.InputEnded:Connect(function(Input, GameProcessedEvent)
if Input == Enum.KeyCode.LeftShift or Input == Enum.KeyCode.LeftControl then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = NormalSpeed
end
end)
this print(Input.KeyCode) prints “Enum.KeyCode.LeftShift”
however, the bug is that when you try to make an if statement or print this print(Input == Enum.KeyCode.LeftShift) it always returns false.
UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
local keyPressed = input.KeyCode
print(keyPressed)
if keyPressed == Enum.KeyCode.LeftShift then
print('THIS MSG NEVER PRINTS!')
end
end
end)
The Input events are still fired if you have ShiftLock enabled, but the gameProcessed will be set to true. Since your code only continues if gameProcessed is false, you get your issue.
The simplest solution is just to remove the if gameProcessed then from the beginning of your code.