|
| 17 Oct 2017 07:42 AM |
Can I make this script cleaner/simplistic?
-------------------------------------------------------------------------
local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() local char = player.CharacterAdded:Wait() local hum = char:WaitForChild("Humanoid")
normWalkSpeed = hum.WalkSpeed WalkSpeedBoost = 8
mouse.KeyDown:connect(function(keypress) if keypress == '0' then hum.WalkSpeed = normWalkSpeed + WalkSpeedBoost end end)
mouse.KeyUp:connect(function(keypress) if keypress == '0' then hum.WalkSpeed = normWalkSpeed end end)
|
|
|
| Report Abuse |
|
|
mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
| |
|
|
| 17 Oct 2017 10:31 AM |
local mouse = player:GetMouse()
mouse.KeyDown:connect(function(keypress) if keypress == '0' then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 22 end end)
mouse.KeyUp:connect(function(keypress) if keypress == '0' then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 14 end end)
I think that would work. |
|
|
| Report Abuse |
|
|
|
| 17 Oct 2017 10:58 AM |
local player = game:GetService("Players").LocalPlayer local input = game:GetService('UserInputService') -- mouse is for noobs local char = player.CharacterAdded:Wait() local hum = char:WaitForChild("Humanoid")
normWalkSpeed = hum.WalkSpeed WalkSpeedBoost = 8
input.InputBegan:connect(function(keypress) if keypress.KeyCode == Enum.KeyCode.0 then -- no need for quotes hum.WalkSpeed = normWalkSpeed + WalkSpeedBoost end end)
input.InputEnded:connect(function(keypress) if keypress.KeyCode == Enum.KeyCode.0 then hum.WalkSpeed = normWalkSpeed end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Oct 2017 11:53 AM |
| At "KeyCode.0" it gives a red line. How can this be fixed? |
|
|
| Report Abuse |
|
|