generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Sprint Script?

Previous Thread :: Next Thread 
milanomaster is not online. milanomaster
Joined: 22 Jan 2013
Total Posts: 252
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 is online. mattscy
Joined: 06 May 2011
Total Posts: 1079
17 Oct 2017 08:40 AM
yes

use UserInputService
Report Abuse
TheIcyJake is not online. TheIcyJake
Joined: 26 Feb 2012
Total Posts: 335
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
musickman14 is not online. musickman14
Joined: 27 Nov 2011
Total Posts: 979
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
milanomaster is not online. milanomaster
Joined: 22 Jan 2013
Total Posts: 252
17 Oct 2017 11:47 AM
Thanks! :D
Report Abuse
milanomaster is not online. milanomaster
Joined: 22 Jan 2013
Total Posts: 252
17 Oct 2017 11:53 AM
At "KeyCode.0" it gives a red line. How can this be fixed?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image