Im not getting any errors, and I don’t know why it’s not working.
local UIS = game:GetService("UserInputService")
local Humanoid = script.Parent:FindFirstChildOfClass("Humanoid")
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) == true then
Humanoid.WalkSpeed = 25
else
Humanoid.WalkSpeed = 16
end
You have to connect UIS to InputBegan for it to start.
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
print("Speed Boost Here")
Humanoid.WalkSpeed = 25
end
end)
The same can be done with InputEnded to make the speed go back to normal.
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
Humanoid.WalkSpeed = 16
end
end)
Yes, so you do use this in a script. You would have to make two separate functions to get the detection for when LeftShift is inputted and then increase the speed, then get the detection for when LeftShift is not inputted anymore and then return the player’s speed back to normal. Using an if else statement in your case wouldn’t exactly work unfortunately. Hope this somewhat helps.
For example
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
UIS.InputBegan:Connect(function(input, gameProcessed) -- starts sprinting
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftControl then
player.Character.Humanoid.WalkSpeed = 25
end
end
end)
UIS.InputEnded:Connect(function(input, gameProcessed) -- no longer starts sprinting
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.LeftControl then
player.Character.Humanoid.WalkSpeed = 16
end
end
end)