Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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
For the shifts, the codes are 47(Right shift), and 48(Left shift). Or you can put key == "/"(Right), key == "0"(Left). OneTruePain 191 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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.

Ad

Answer this question