Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

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

Asked by
Pxryk -4
5 years ago

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)

0
code block, this is impossible to read Gameplayer365247v2 1055 — 5y
0
I have a minor headache and reading this worsens it. Please use code blocks! Y_VRN 246 — 5y

1 answer

Log in to vote
0
Answered by
Y_VRN 246 Moderation Voter
5 years ago

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.

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. Y_VRN 246 — 5y
0
What even happened to my question? ShutokouBattle 227 — 5y
0
^ answer* ShutokouBattle 227 — 5y
Ad

Answer this question