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

Press key then run script?

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

1 comment

0

here is the script for holding R to change your walkspeed (if you want a different keybind, explained in script)

3 answers

✓ Accepted answer

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)

1 comment

0

can you make it so when we press r once it will run? and when we press it again

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

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