UserInputService = game:GetService("UserInputService") local players = game.Players.LocalPlayer
local LeftShiftPressed = false
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent) if input.KeyCode == Enum.KeyCode.LeftShift then LeftShiftPressed = true if players:FindFirstChild("Humanoid") then players.Humanoid.CharacterWalkSpeed = 90
UserInputService.InputBegan:Connect(function(input,gameProccesedEvent) if input.KeyCode == Enum.KeyCode.LeftShift then LeftShiftPressed = false if players:FindFirstChild("Humanoid") then players.Humanoid.CharacterWalkSpeed = 16 end end
end)
while LeftShiftPressed == true do wait() players.Humanoid.CharacterWalkSpeed = 90 end
So your not actually grabbing the player's character where the humanoid is. Instead of doing players:FindFirstChild("Humanoid"), create a variable for the character and replace players with it.
local UserInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() UserInputService.InputBegan:Connect(function(input,gameProcessed) --if not gameProcessed then if input.KeyCode == Enum.KeyCode.LeftShift then if players:FindFirstChild("Humanoid") then players.Humanoid.CharacterWalkSpeed = 90 end end --end end
Also, instead of using a loop to check if the player is sprinting, use the InputEnded function.
UserInputService.InputEnded:Connect(function(input,gameProcessed) --if not gameProcessed then if input.KeyCode == Enum.KeyCode.LeftShift then if players:FindFirstChild("Humanoid") then players.Humanoid.CharacterWalkSpeed = 16 end end --end end
if you want the player to sprint while using chat, keep the gameprocessed and the end that goes with it commented. If you do uncomment them, the player won't be able to sprint while using shift-lock.