Move In the same Velocity when you leave the ground

I created a simple mechanic where when you jump or fall off a taller surface you will continue falling at the same speed that you left the surface, instead of instantly stopping in mid-air when you stop walking, which is the default.

How to Use:

  1. Copy Code and paste in a local script
  2. Place Local Script in Game > StarterPlayer > StarterPlayerScripts
  3. Enjoy

Code:

--services
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

--constants
local PLAYER = Players.LocalPlayer
local CHARACTER = PLAYER.Character or PLAYER.CharacterAdded:Wait()
local HUMANOID = CHARACTER:WaitForChild("Humanoid")

--variables
local lastVelocity = Vector3.new(0,0,0)
local isOnGround = true

RunService.Stepped:Connect(function()
	if HUMANOID.FloorMaterial == Enum.Material.Air then -- in air
		if isOnGround then -- just left the ground
			lastVelocity = HUMANOID.RootPart.Velocity
		end
		HUMANOID.RootPart.Velocity = Vector3.new(lastVelocity.X, HUMANOID.RootPart.Velocity.Y, lastVelocity.Z)
		isOnGround = false
	else
		isOnGround = true
	end
end)
13 Likes