How do I add a sliding script that slows down the longer you are sliding?

Hello! how do I make a sliding system that slowly slows down the long the player is sliding. I have currently figured out how to stop it, when the player has jumped or is jumping. And I also made it if the player is moving it can slide.

So how can I achieve this, please help.

Help is very much needed and thanked!

-- Sliding
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.C and hum.MoveDirection.Magnitude > 0 then
		local slideVelocity = Instance.new("BodyVelocity")
		slideVelocity.MaxForce = Vector3.new(hum.WalkSpeed, 0, 0) * 2500
		slideVelocity.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
		slideVelocity.Parent = char.HumanoidRootPart
		hum.StateChanged:Connect(function(old, new)
			if new == Enum.HumanoidStateType.Jumping or new == Enum.HumanoidStateType.Freefall then
				slideVelocity:Destroy()
			end
		end)
		wait(0.5)
		slideVelocity:Destroy()
	end
end)

Thanks!

1 Like

Hope this helps!