How do i make a script so when a player presses a key (R) they run faster?
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)
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)
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