Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make this script take 5 seconds to be at max speed?

how do i make it so when i click shift it takes about 5 seconds to reach max speed?? : repeat wait() until game.Players.LocalPlayer m = game.Players.LocalPlayer:GetMouse() m.KeyDown:connect(function(key) if key == "0" then --"Shift to run" 0 == shift print("Running") game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 32 --change "25" to your speed you want end end) m.KeyUp:connect(function(key) if key == "0" then game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 --change "16" to your speed you want when you stop running end end)

2 comments

0

code block, this is impossible to read

0

I have a minor headache and reading this worsens it. Please use code blocks!

1 answer

After reading and organizing the eye straining question on my end, I finally came up with a solution...

Here it is.

-- PUT THIS CODE IN A LOCALSCRIPT UNDER THE StarterCharacterScripts!

-- Game > StartPlayer > StarterCharacterScripts

  

repeat
	wait()
until game.Players.LocalPlayer
  
m = game.Players.LocalPlayer:GetMouse()
  
local TweenService = game:GetService("TweenService")
  
local maxSpeed = 32 -- Use this variable instead to change the speed.
  
local goal1 = {}
local goal2 = {}
  
local humanoid = script.Parent.Humanoid -- It's best to use variables.
  
goal1.WalkSpeed, goal2.WalkSpeed = 16,maxSpeed
  
local TweenInf = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
  
local slowDown,speedUp = TweenService:Create(humanoid,TweenInf,goal1),TweenService:Create(humanoid,TweenInf,goal2)
  
m.KeyDown:Connect(function(key)
	if key == "0" then --“Shift to run” 0 == shift
		print("Running")
		speedUp:Play()
	end
end)
m.KeyUp:Connect(function(key)
	if key == "0" then
		slowDown:Play()
	end
end)

By the way, ^ ^ ^ ^ THIS ^ ^ ^ ^ is a code block.

3 comments

0

Forgot to mention. To copy the code properly, hover your mouse over the code block until you find a popup on the top-right corner. Click the copy icon (if it's a puzzle, click it and allow Flash to load) and you're done.

0

What even happened to my question?

0

^ answer*

This discussion is preserved as it was. New answers, comments, and votes are closed.