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)