I'm making a game and one part is if you are moving/running and you press left shift an aura will appear and you'll go faster, like in Sonic games. I tried one script, but when I used it it rarely worked. Sometimes I would let go of left shift and there would be a long delay before the aura went away. This script didn't include the part where you have to be running though. The aura also had particles on it and I made it so they would appear with the aura when left shift was pressed, but they wouldn't appear. I'm using this for a StarterCharacter so the script is a local script in StarterCharacterScripts. If anyone knows how to do this so it works all the time then I would appreciate it!
Thanks.
1 | local plr = game.Players.LocalPlayer -- defines player |
2 | local char = plr.Character or plr.CharacterAdded:Wait() -- defines character |
3 | local uis = game:GetService( "UserInputService" ) -- shorter defintion |
4 | local walk = 16 -- our walk value |
5 | local sprint = 32 -- our running/sprinting value |
1 | uis.InputBegan:Connect( function (key) |
2 |
3 | end ) |
4 |
5 | uis.InputEnded:Connect( function (key) |
6 |
7 | end ) |
01 | uis.InputBegan:Connect( function (key) |
02 | if key.KeyCode = = Enum.KeyCode.LeftShift then |
03 |
04 | end |
05 | end ) |
06 |
07 | uis.InputEnded:Connect( function (key) |
08 | if key.KeyCode = = Enum.KeyCode.LeftShift then |
09 |
10 | end |
11 | end ) |
01 | uis.InputBegan:Connect( function (key) |
02 | if key.KeyCode = = Enum.KeyCode.LeftShift then |
03 | char.Humanoid.WalkSpeed = sprint |
04 | end |
05 | end ) |
06 |
07 | uis.InputEnded:Connect( function (key) |
08 | if key.KeyCode = = Enum.KeyCode.LeftShift then |
09 | char.Humanoid.WalkSpeed = walk |
10 | end |
11 | end ) |
01 | local plr = game.Players.LocalPlayer |
02 | local char = plr.Character or plr.CharacterAdded:Wait() |
03 | local uis = game:GetService( "UserInputService" ) |
04 | local walk = 16 |
05 | local sprint = 32 |
06 |
07 | uis.InputBegan:Connect( function (key) |
08 | if key.KeyCode = = Enum.KeyCode.LeftShift then |
09 | char.Humanoid.WalkSpeed = sprint |
10 | end |
11 | end ) |
12 |
13 | uis.InputEnded:Connect( function (key) |
14 | if key.KeyCode = = Enum.KeyCode.LeftShift then |
15 | char.Humanoid.WalkSpeed = walk |
16 | end |
17 | end ) |