Go faster when sliding

I want it to be that when I slide I go faster the longer I slide, but when I stop sliding my speed will return to normal

here is my script:

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char.Humanoid



UIS.InputBegan:Connect(function(input,GPE)
	if input.UserInputType == Enum.UserInputType.Keyboard  then
		if input.KeyCode == Enum.KeyCode.LeftControl then
			while true do 
				hum.WalkSpeed = hum.WalkSpeed + 5
				print(hum.WalkSpeed)
				wait(1)
				UIS.InputEnded:Connect(function(hit)
					if input.UserInputType == Enum.UserInputType.Keyboard  then
						if input.KeyCode == Enum.KeyCode.LeftControl  then
							hum.WalkSpeed = 16
							print("Break?")
							return
						end
					end
				end)
			end
		end
	end
end)```

What is the problem? I don’t understand here!

so, I want the player to go faster the longer they slide, but when they stop sliding the player’s speed goes to normal

What your are doing, is it working or no.

what I am not doing is: I’m sliding, but the longer I slide the faster I go. this is what I need your help with
it is not working, I want to go faster the longer I slide, but when I stop sliding, my WalkSpeed goes back to 16.

So basically: the longer I slide the faster I go, but if I stop Sliding, My speed goes back to normal (16)

1 Like

Yes, but is it working how you want it or no.

1 Like

It is not working the way I would like it to.

Can you tell me what doesn’t work about it?

when you start sliding, you do go faster, but you don’t slow down

					if input.UserInputType == Enum.UserInputType.Keyboard  then
						if input.KeyCode == Enum.KeyCode.LeftControl  then
							hum.WalkSpeed = 16
							print("Break?")
							return
						end
					end
				end)```
I believe that the problem  is in that code block

sorry about the communication errors

Change

				UIS.InputEnded:Connect(function(hit)
					if input.UserInputType == Enum.UserInputType.Keyboard  then
						if input.KeyCode == Enum.KeyCode.LeftControl  then
							hum.WalkSpeed = 16
							print("Break?")
							return
						end
					end
				end)

To

				UIS.InputEnded:Connect(function(input2)
					if input2.UserInputType == Enum.UserInputType.Keyboard  then
						if input2.KeyCode == Enum.KeyCode.LeftControl  then
							hum.WalkSpeed = 16
							print("Break?")
							return
						end
					end
				end)

Change the speed, i just edited the code so it prints “break?”

that almost worked, but if I press control, then the speed will go up, and when I let go of control, then the speed keeps going up, and when I hit control again, it just resets the speed and then goes up.

ngl dude, it’s better to use UserInputService:IsKeyDown()

1 Like

want a code for it?

chaaarrrrssss

sure I’ll take a code for it

I need 8 more characters

1 Like

here is a simple script, you can change it (or ask me to change it) if you want something that i didn’t do

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 slideSpeed = 20 --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
		humanoid.WalkSpeed = slideSpeed
	else
		humanoid.WalkSpeed = 16
	end
end)

that worked the best so far thank you!, however, the speed stays the same but I’m happy with this

what do you mean stays the same? doesnt get added or doesnt get removed?
(this wasn’t tested btw)

It doesn’t add speed, but it does go back to normal speed

it doesn’t add??? i just checked the script, it works perfectly fine??? adds and removes? its supposed to be 20 (which is barely any change) you might want to check properties of humanoid or increase…