I'm creating a game that involves moving parts mid-air. I've run into a problem when the character jumps or falls (falling only applies for this if network ownership is under another player), all of their momentum/velocity is lost. This is an issue because laggy people and/or jumping will cause a player to lose their momentum mid-air, which is not intended behavior.

Here is the script I've tried. This was made in under 5 minutes, don't worry about how it is formatted or done, I just need to know how to make the character keep their momentum when moving off a moving object.

local char = script.Parent
local hum = script.Parent:WaitForChild("Humanoid")
local root = script.Parent:WaitForChild("HumanoidRootPart")

local states = {Enum.HumanoidStateType.Freefall,Enum.HumanoidStateType.Jumping}
local prev
local updating = true

game["Run Service"].RenderStepped:Connect(function()
	if updating then
		prev = root.AssemblyLinearVelocity
	end
end)

hum.StateChanged:Connect(function(state)
	print(state)
	local falling = false
	for i,v in pairs(states) do
		if v == state then
			falling = true
		end
	end
	if falling == true then
		updating = false
		root.AssemblyLinearVelocity = prev
		
	else
		updating = true
	end
end)