Hey yall, i just tried making a simple sprint script, and i cant figure out why this code is working, im still pretty new to all this so im trying to figure it out
local UserInputService = game:GetService("UserInputService")
local players = game.Players
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.KeyCode.LeftShift then
char.Humanoid.Walkspeed = 32
end
end)
end)
end)
it doesnt give any errors whatsoever, but it also doesnt work
You need to make the code local and place it in starter player scripts, try this:
local plr = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode== Enum.KeyCode.LeftShift then
plr.Character.Humanoid.Walkspeed = 32
end
end)