I need help making a hold shift to run script, anyone know how to?
Attention to any mods, if I'm breaking any rules please let me know - I will take my answer down.
So, I'm going to use many comments to explain what's happening so this person can learn.
Read this script - the comments too, hope this helps..
print("Sprint Script Loaded") -- You must put this in a local script because it's handling user input -- This script should go in StarterPlayer > StarterCharacterScripts -- We can only access LocalPlayer in a LocalScript it cannot be accessed in a server script nor ModuleScript player = game.Players.LocalPlayer mouse = player:GetMouse() -- This is what will be detecting if you pressed a key -- Here we create a function with a parameter 'key' key is the key that was pressed local function onKeyDown(key) -- This checks to see if the key code is the same as shift if string.byte(key) == 48 then -- 48 is the keycode to shift player.Character.Humanoid.WalkSpeed = 29 -- This is changing the persons walkspeed end end local function onKeyUp(key) -- a function going to be fired when a key is released if string.byte(key) == 48 then -- Again here we check to see if it's the shift key player.Character.Humanoid.WalkSpeed = 16 -- Here we are changing the walkspeed back to default which is 16 end end -- Here we are connecting the two functions to the 'KeyDown' and 'KeyUp' events. mouse.KeyDown:connect(onKeyDown) mouse.KeyUp:connect(onKeyUp)
not a specific question about scripting, that's more of a "give me stuff i need which i wont make the effort to think a lot about" however, you could start by:
local plr = ... local mouse = plr:GetMouse() mouse.KeyDown:connect(function(key) if key == "r" then .... end end) mouse.KeyUp:connect(function(key) if key == "r" then ... end end)
Idk how to refer to shift
Closed as Not Constructive by theCJarmy7, TheeDeathCaster, xAtom_ik, and InfinitivePixelsJr
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?