How to smoothen this out

All I want to do is smoothen out the movement (in video 1), to the movement in video 2, however, the issue is is that the parts are moved apart in vid 1, how i want it to be, but in vid 2, they are not.

VIDEO 1

VIDEO 2

CODE:

task.wait(3)

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Player = Players:GetPlayers()[1]

print("Player found: "..Player.Name)


local Speed = 20

local Points = {CFrame.new(0, 1.5, 0)}

local Time = 0
local Carriges = 30
local OverallDeltaTime = 0

local stop = false

RunService.Heartbeat:Connect(function(DeltaTime)
	OverallDeltaTime += DeltaTime
	if OverallDeltaTime >= 0 then
		if stop then
			return
		end
		Time += DeltaTime
		table.insert(Points, 1, Points[1]:ToWorldSpace(CFrame.new(Speed * OverallDeltaTime, 0, 0)))
		for Count, Object in pairs(workspace.Parts:GetChildren()) do
			if Count < #Points then
				Object.CFrame = Points[Count]
			end
		end
		OverallDeltaTime = 0
	end
end)

for Count=2, Carriges do
	local Part = workspace.Parts[1]:Clone()
	Part.Parent = workspace.Parts
	Part.Name = Count
end

UserInputService.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then
		local Part = workspace.Parts[1]:Clone()
		Part.Parent = workspace.Parts
		Part.Name = #workspace.Parts:GetChildren()
	elseif Input.KeyCode == Enum.KeyCode.One then
		Points[1] = Points[1] * CFrame.Angles(0, math.rad(90), 0)
	elseif Input.KeyCode == Enum.KeyCode.Two then
		Points[1] = Points[1] * CFrame.Angles(0, math.rad(-90), 0)
	elseif Input.KeyCode == Enum.KeyCode.Three then
		Points[1] = Points[1] * CFrame.Angles(math.rad(90), 0, 0)
	elseif Input.KeyCode == Enum.KeyCode.Four then
		Points[1] = Points[1] * CFrame.Angles(math.rad(-90), 0, 0)
	end
end)


2 Likes

use tweens? i dont understand the premise of your needs.

The problem here is only that you are not taking the size of the individual bricks into account, instead just transforming them by the total time. I ran your code, and multiplying your new CFrames’ X values by three seems to do the trick:

CFrame.new(3 * Speed * OverallDeltaTime, 0, 0)

I hope this helps you, my friend. Looking forward to what you do next.

it still does not work as now the bus moves rapidly

I might be able to help you out here, if you can simplify what you’re trying to say

if i add the 3*, it boosts the speed by 3