Jumping while on moving object

I am trying to achieve the ability to jump on moving objects while keeping the momentum of that object,
Example of problem:
I have tried multiple solutions including the ‘jailbreak train’ thing, nothing has worked. I have spent, collectively, at least 8 hours trying to figure this out.

My idea was originally to get the velocity of the ship, velocity of the player as they jump, and add the two but I quickly realized that just doesn’t work. At this point, I have no clue what to do.
The issue with the ‘jailbreak train’ script is that it is constantly moving me forward on the ship, which would cause me to fall off.

Here is the jailbreak script in case you want to see it(Credit to Kord_K):

local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')

local LastTrainCFrame

local Function
local Function2

Function = RunService.Heartbeat:Connect(function()

--------------------------------------------------------------- CHECK PLATFORM BELOW

local RootPart = player.Character.LowerTorso

local Ignore = player.Character

local ray = Ray.new(RootPart.CFrame.p,Vector3.new(0,-50,0))

local Hit, Position, Normal, Material = workspace:FindPartOnRay(ray,Ignore)

if Hit and Hit.Name == "RaftTop" then -- Change "RaftTop" to whatever the moving part's name is

--------------------------------------------------------------- MOVE PLAYER TO NEW POSITON FROM OLD POSITION

local Train = Hit
if LastTrainCFrame == nil then -- If no LastTrainCFrame exists, make one!
	LastTrainCFrame = Train.CFrame -- This is updated later.
local TrainCF = Train.CFrame 

local Rel = TrainCF * LastTrainCFrame:inverse()

LastTrainCFrame = Train.CFrame -- Updated here.

RootPart.CFrame = Rel * RootPart.CFrame -- Set the player's CFrame

LastTrainCFrame = nil -- Clear the value when the player gets off.


Function2 = player.Character.Humanoid.Died:Connect(function()
	Function:Disconnect() -- Stop memory leaks
	Function2:Disconnect() -- Stop memory leaks


Example of the issue I am having with this script(Ignore the unanchored, collapsing buildings in the background): gyazolink

So, any idea on what I should do? Again, I’ve tried the above script, welding (idk why), something similar to the above but custom, and many many other things. Am I just missing something?

This is my first time creating a new Topic, so sorry if I messed a few things up.


Was your issue fixed? I want to achieve the same goal as you, so I don’t know how to do so as well.