Go faster when sliding

you do go faster when you slide, sorry I didn’t make that clear, what I meant was it stays at 20 and doesn’t go higher, and when you stop sliding the speed goes back down, so the script work fine except you don’t go any faster than 20, and by that, I mean you start at 20 but no matter how long you slide your speed stays at 20

you never said you wanted it to increase gradually… imma make it rq, how much time does it need to wait before adding 1 to the speed?

one second would be optimal
spacefiller

1 Like

it goas up a bit too fast, you can change it tho! (or ask me to)

local players = game:GetService("Players")
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")

local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait() --making sure the character loads
local humanoid = character:WaitForChild("Humanoid")

local isSliding = false
local isAdding = false

local slideSpeed = 20 --change
local delayBetweenAdding = 1 --change
local addAmountAfterDelay = 1 --change

local slideKeycode = Enum.KeyCode.LeftControl

userInputService.InputBegan:Connect(function()
	if userInputService:IsKeyDown(slideKeycode) then
		isSliding = true
	end
end)

userInputService.InputEnded:Connect(function()
	if not userInputService:IsKeyDown(slideKeycode) then
		isSliding = false
	end
end)

runService.RenderStepped:Connect(function()
	if isSliding then
		if isAdding then
			spawn(function() --spawning the loop so it doesn't stop the rest of the script
				while wait(1) do
					if not isSliding then break end --ending when he stops sliding
					humanoid.WalkSpeed += 1
				end
			end)
		else
			isAdding = true
			humanoid.WalkSpeed = slideSpeed
		end
	else
		isAdding = false
		humanoid.WalkSpeed = 16
	end
end)
2 Likes

Thanks! that worked great! sorry I was unclear at some points

all good man! if you want anything feel free to ask, Glad I was able to help you!

1 Like
local Game = game
local UserInputService = Game:GetService("UserInputService")
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")

local Connection

local function OnRenderStep(Delta)
	Humanoid.WalkSpeed += Delta
end

local function OnInputBegan(InputObject, GameProcessed)
	if GameProcessed then return end
	if InputObject.KeyCode.Name ~= "LeftControl" then return end
	if Connection and Connection.Connected then return end
	Connection = RunService.RenderStepped:Connect(OnRenderStep)
end

local function OnInputEnded(InputObject, GameProcessed)
	if GameProcessed then return end
	if InputObject.KeyCode.Name ~= "LeftControl" then return end
	if Connection then Connection:Disconnect() end
	Humanoid.WalkSpeed = 16
end

UserInputService.InputBegan:Connect(OnInputBegan)
UserInputService.InputEnded:Connect(OnInputEnded)

You’re employing a few questionable practices inside of your ‘RenderStepped’ event loop.