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

Press key then run script?

Asked by 10 years ago

How do i make a script so when a player presses a key (R) they run faster?

0
here is the script for holding R to change your walkspeed (if you want a different keybind, explained in script) fcvrs 22 — 3y

3 answers

Log in to vote
2
Answered by
AxeOfMen 434 Moderation Voter
10 years ago

Place this code in a LocalScript. Holding 'r' will cause the player to run faster. Releasing 'r' returns the player to the original walk speed.

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local mouse = player:GetMouse()
local origSpeed = humanoid.WalkSpeed
local runSpeed = 100 --modify this value to be the speed you want when running

mouse.KeyDown:connect(function(key)
    if key:lower() == "r" then
        humanoid.WalkSpeed = runSpeed       
    end
end)

mouse.KeyUp:connect(function(key)
    if key:lower() == "r" then
        humanoid.WalkSpeed = origSpeed
    end
end)
0
can you make it so when we press r once it will run? and when we press it again gamekiller124422 0 — 3y
Ad
Log in to vote
1
Answered by 10 years ago

You're going to use the .KeyDown() function.

You're going to have to get the players mouse.

Read: http://wiki.roblox.com/index.php/KeyDown_(Event)

0
I know that.... masterhalo55 75 — 10y
Log in to vote
-1
Answered by 10 years ago

If you want the script, then look here.

NOTE: Added some tags for your understanding.

repeat wait() until game.Players.LocalPlayer--Also, this is local script because this is being used by the player
local p = game.Players.LocalPlayer--P is for players
local m = p:GetMouse()--m is for mouse

m.KeyDown:connect(function(key)
I key: lower() == "R" then--R is for run

Sorry not full answer, I forgot what to do XD

Answer this question