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)
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.