Hi. I wanted to make a shift to sprint script for my game. I tried to do it myself but realized I should just try a tutorial instead, so I did. The script actually worked, but unfortunately, it didn’t work in the way I intended. Instead of doing shift to sprint, you had to press 0 to sprint instead. I know it says “0” in the code, but I tried changing it to “Shift” or “LeftShift” to no avail. I even replaced the “key == 0” part with an Enum.KeyCode, and it still didn’t work. Can someone please help with this? The code is below:
local playerservice = game:GetService("Players")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local sprintSpeed = 30
mouse.KeyDown:Connect(function(key)
if key == "0" then
player.Character.Humanoid.WalkSpeed = sprintSpeed
end
end)
mouse.KeyUp:Connect(function(key)
if key == "0" then
player.Character.Humanoid.WalkSpeed = 16
end
end)
Thanks!