Hi, I have an issue. I have a CFrameValue instances and they are numerically orderd. I have a function to connect a line between them but this function takes position 1 and position 2 and creates a line. The problem is, I do not know how to use to use the function and connect all the lines which are numerically orderd.
PositionAt = 0 -- Number used to mark where the Part is currently
Part = script.Parent
Positions = {
[1] = Vector3.new(0,0,0);
[2] = Vector3.new(0,10,0);
}
for i = 1,#Positions do
wait(1)
PositionAt += 1
Part.Position = Positions[PositionAt]
end
if you want, you can use TweenService which would look something like this:
TS = game:GetService("TweenService")
Part = script.Parent
PositionAt = 0
Positions = {
[1] = Vector3.new(0,0,0);
[2] = Vector3.new(0,10,0);
}
for i = 1,#Positions do
wait(1)
PositionAt += 1
TS:Create(Part, TweenInfo.new(1), {Position = Positions[PositionAt]}):Play()
end
local LastPosition
for i, Position in ipairs([PUT CONTAINER FOR VALUES HERE]:GetChildren()) do
if i == 1 then LastPosition = Position.Value continue end
local Part = Instance.new("Part")
Part.Size = Vector3.new(1, 10, (LastPosition - Position.Value).Magnitude)
Part.CFrame = CFrame.lookAt(LastPosition, Position.Value):ToWorldSpace(CFrame.new(0, Part.Size.Y / 2, -Part.Size.Z / 2))
Part.Anchored = true
Part.Parent = workspace
LastPosition = Position.Value
end
this only works if you use vector3 values (I don’t see a reason why you should use cframe values over vector3 values)
CFrame sets both Position and Orientation of an Object while Vector3 only sets the position. although you can set Orientation with Vector3, i still perfer CFrame
Correct me if i am wrong but are we not just making a line between the dots? (I am assuming Luftalagi only has the position of the dots and not the required CFrame)