Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What would i need to add the following to a tool?

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)


1 comment

1

For the shifts, the codes are 47(Right shift), and 48(Left shift). Or you can put key == "/"(Right), key == "0"(Left).

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.