This was a YouTube tutorial but I have slightly adjusted a few of its properties to make it work.
I’m using Runservice.Stepped so it constantly matches the velocity of the player with the moving model. But I don’t get those results?
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
local positionStart = CFrame.new(11.409, -0.378, -268.977)
local positionEnd = CFrame.new(11.409, -0.378, -305)
local object = script.Parent
local objectRoot = object.PrimaryPart
local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Back, Enum.EasingDirection.InOut, -1, true)
local tweenFunction = tweenService:Create(objectRoot, tweenInfo, {
CFrame = objectRoot.CFrame * CFrame.new(0,0,-30)
})
while true do
tweenFunction:Play()
wait(1)
end
local lastPosition = objectRoot.Position
runService.Stepped:Connect(function(_, deltaTime)
local currentPosition = objectRoot.Position
local deltaPosition = currentPosition - lastPosition
local deltaTime = 0.016666
local velocity = deltaPosition / deltaTime
objectRoot.AssemblyLinearVelocity = velocity
lastPosition = currentPosition
end)