local Speed = 20
for i, folder in ipairs(workspace.TrainTest.Path:GetChildren()) do
local Positions = {}
for i, parts in ipairs(folder:GetChildren()) do
Positions[tonumber(parts.Name)] = parts.Position
parts:Destroy()
end
local TotalDistance = 0
local CFrames = {}
for i = 1, #Positions do
local PreviousI = i - 1
if PreviousI == 0 then PreviousI = #Positions end
local Offset = Positions[i] - Positions[PreviousI]
CFrames[i] = CFrame.lookAt(Positions[i], Positions[i] + Offset)
local Part = Instance.new("Part")
Part.Anchored = true
Part.CanCollide = false
Part.CanTouch = false
Part.CFrame = CFrames[i] * CFrame.fromOrientation(0, math.pi / 2, 0)
Part.Position -= Offset * 0.5
Part.Size = Vector3.new(Offset.Magnitude, 0.5, 0.5)
Part.Shape = Enum.PartType.Cylinder
Part.Color = Color3.new(0.1, 0.1, 0.1)
Part.TopSurface = Enum.SurfaceType.Smooth
Part.BottomSurface = Enum.SurfaceType.Smooth
Part.Parent = folder
TotalDistance += Offset.Magnitude
end
local StartCFrame = CFrame.lookAt(Positions[1], Positions[2])
local Amount = math.round(TotalDistance / 100)
local WaitTime = TotalDistance / Amount / Speed
local Targets = {}
for i = 1, 1 do
local Target = Instance.new("Part")
Target.Anchored = true
Target.CanCollide = false
Target.CanTouch = false
Target.CFrame = StartCFrame
Target.Size = Vector3.new(0,0,0)
#Train Problem: Not moving
1 messages · Page 1 of 1 (latest)
Target.Transparency = 1
Target.Parent = folder
local Attachment1 = Instance.new("Attachment", Target)
local Model = game.ServerStorage.Models[folder.Name]:Clone()
Model:SetPrimaryPartCFrame(StartCFrame)
Model.Parent = folder
local Attachment0 = Instance.new("Attachment", Model.PrimaryPart)
local AlignPosition = Instance.new("AlignPosition")
AlignPosition.Attachment0 = Attachment0
AlignPosition.Attachment1 = Attachment1
AlignPosition.MaxForce = math.huge
AlignPosition.MaxVelocity = Speed
AlignPosition.Responsiveness = 200
AlignPosition.Parent = folder
local AlignOrientation = Instance.new("AlignOrientation")
AlignOrientation.Attachment0 = Attachment0
AlignOrientation.Attachment1 = Attachment1
AlignOrientation.MaxTorque = math.huge
AlignOrientation.MaxAngularVelocity = 5
AlignOrientation.Responsiveness = 10
AlignOrientation.Parent = folder
table.insert(Targets, Target)
end
spawn(function()
wait(5)
local i = 1
while true do
local NextI = i + 1
if NextI > #Positions then NextI = 1 end
local Magnitude = (Positions[NextI] - Positions[i]).Magnitude
i = NextI
spawn(function()
for i, Target in ipairs(Targets) do
Target.CFrame = CFrames[NextI]
wait(WaitTime)
end
end)
wait(Magnitude / Speed)
end
end)
end
Fixed the problem, I've removed the WeldConstraints and added Welds instead.
However, new problem.
https://gyazo.com/e5f87aa19c4d872fc829558a45d2452d
I'm still seeking help for this problem ^
Only reason I can think of that WeldConstraints wouldn't work where Welds do is that you're welding to something anchored on the first approach and not in the latter, that's the only circumstance under which a WeldConstraint will freeze an assembly
i.e. toggle Massless type drip...
I guess, but now the model is moving sideaways, any hint?