A shift - to - sprint function, like if you press shift with the tool equiped you have sprint with custon animation just put it as [exampleAnim]
local tool = script.Parent tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "q" then print("Switching to next weapon") elseif key == "e" then print("Switching to previous weapon") end end) end)
As @OneTruePain said, the keycodes for the shift keys on your keyboard are "/"
and "0"
. So if you detect when key
is equal to either one of them, you'll be telling when shift is down.
To change the walk speed of a Humanoid object, change the property Humanoid.WalkSpeed.
To make the running stop, you'll have to detect when the user stops pressing shift. Look at the event Mouse.KeyUp for details.