When shift pressed sprint not working

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)

Thanks for the quick reply, but it says walkspeed isnt a valid member of humanoid

Change it to WalkSpeed not Walkspeed

Yess, that works, thank u so much

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.