Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
|
| 29 Dec 2016 02:26 PM |
This is basically a shift to sprint script, but the problem is, with two keys being pressed down other than LeftShift, the FOV can be glitched. I also would like a cooldown and a limit on sprinting, but I have no clue on where to put this. Can anyone help?
Code: uis.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = true local conn = uis.InputEnded:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = false end end) for i = 0,9 do workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView + 1 wait() end char.Humanoid.WalkSpeed = 20 repeat wait() until running == false conn:Disconnect() char.Humanoid.WalkSpeed = 16 for i = 0,9 do workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView + 1 wait() end end end)
~Korniak |
|
|
| Report Abuse |
|
|
Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
| |
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
|
| 29 Dec 2016 02:54 PM |
I edited your code, try it out.
uis.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = true local conn = uis.InputEnded:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = false end end) for i = 0,9 do if running then workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView + 1 wait() end end char.Humanoid.WalkSpeed = 20 repeat wait() until running == false conn:Disconnect() char.Humanoid.WalkSpeed = 16 for i = 0,9 do if not running then workspace.CurrentCamera.FieldOfView = workspace.CurrentCamera.FieldOfView + 1 wait() end end end end) |
|
|
| Report Abuse |
|
|
Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
|
| 29 Dec 2016 02:58 PM |
Fixed the FOV bug because of a small mistake.
All that's left now is the cooldown and limit on sprinting.
~Korniak |
|
|
| Report Abuse |
|
|
Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
| |
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
|
| 29 Dec 2016 03:20 PM |
| local running = false local userInputService = game:GetService("UserInputService") userInputService.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = true end end) userInputService.InputEnded:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = false end end) spawn(function() local lastState = running while wait() do if ######### ## running then if running then char.Humanoid.WalkSpeed = 20 for i = 1, 10 do if not running break end cam.FieldOfView = cam.FieldOfView + 1 end else char.Humanoid.WalkSpeed = 16 for i = 1, 10 do if not running break end cam.FieldOfView = cam.FieldOfView - 1 end end end end end) |
|
|
| Report Abuse |
|
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
|
| 29 Dec 2016 03:23 PM |
| local running = false local userInputService = game:GetService("UserInputService") userInputService.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = true end end) userInputService.InputEnded:connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then running = false end end) spawn(function() local lastState = running while wait() do if ######### ## running then lastState = running if running then char.Humanoid.WalkSpeed = 20 for i = 1, 10 do if not running break end cam.FieldOfView = cam.FieldOfView + 1 end else char.Humanoid.WalkSpeed = 16 for i = 1, 10 do if running break end cam.FieldOfView = cam.FieldOfView - 1 end end end end end) |
|
|
| Report Abuse |
|
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
| |
|
Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
| |
|
Korniak
|
  |
| Joined: 09 Aug 2013 |
| Total Posts: 3538 |
|
|
| 29 Dec 2016 05:22 PM |
Still need to mend in a way for a cooldown and a limit on scripting
Thanks if anyone can help.
~Korniak |
|
|
| Report Abuse |
|
|