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

Does anyone know how to make a hold shift to run script? and when u stop holding down sprint stops? [closed]

Asked by 7 years ago

I need help making a hold shift to run script, anyone know how to?

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?

2 answers

Log in to vote
0
Answered by 7 years ago

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..

01print("Sprint Script Loaded")
02-- You must put this in a local script because it's handling user input
03-- This script should go in StarterPlayer > StarterCharacterScripts
04 
05-- We can only access LocalPlayer in a LocalScript it cannot be accessed in a server script nor ModuleScript
06 
07player = game.Players.LocalPlayer
08 
09mouse = player:GetMouse() -- This is what will be detecting if you pressed a key
10 
11 -- Here we create a function with a parameter 'key' key is the key that was pressed
12 
13local function onKeyDown(key)
14-- This checks to see if the key code is the same as shift
15if string.byte(key) == 48 then -- 48 is the keycode to shift
View all 29 lines...
Ad
Log in to vote
0
Answered by 7 years ago

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:

01local plr = ...
02local mouse = plr:GetMouse()
03 
04mouse.KeyDown:connect(function(key)
05if key == "r" then
06....
07end
08end)
09mouse.KeyUp:connect(function(key)
10if key == "r" then
11...
12end
13end)

Idk how to refer to shift

0
Kiriyato, Actually you can refer to shift using the key code 48 like this - string.byte(key) and use an if statement to see if it is that same key code. andyad13 74 — 7y