-
What do you want to achieve? I want to make a working minecart that follows parts in order.
-
What is the issue? The minecart doesnt follow the parts in order.
-
What solutions have you tried so far? DevFourm and I tried lerping.
Here is a video I have of the problem
I did make sure to name each part in order.
local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Minecart = Lighting.MinecartObject:Clone()
local MinecartMainPart = Minecart.MainPart
local Positions = game.Workspace.MinecartPositions
wait(1)
local PositionTable = {}
Minecart.Parent = game.Workspace
MinecartMainPart.CFrame = Positions[1].CFrame
local TInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
for f,l in pairs(MinecartMainPart:GetChildren()) do
if l.Name == "Seat" then
l:GetPropertyChangedSignal("Occupant"):Connect(function()
for i,v in pairs(Positions:GetChildren()) do
table.insert(PositionTable,v.Name)
print(PositionTable)
table.sort(PositionTable)
for _,q in pairs(PositionTable) do
if q == v.Name then
local Goal = {} -- This part will be explained later.
Goal.CFrame = v.CFrame
local Tween = TweenService:Create(MinecartMainPart, TInfo, Goal)
Tween:Play()
end
end
wait(1)
end
end)
end
end
for i,v in pairs(game.Workspace.MinecartPositions:GetChildren()) do
local tab = {}
table.insert(tab,v.Name[1])
local p = Instance.new("Part")
p.Parent = game.Workspace
p.CFrame = v.CFrame + Vector3.new(0,3,0)
p.Name = i
end