I’m trying to make a doors similar game but these won’t go in order. it prints 2 the 1 when its supposed to go 1 then 2.
for _, Room in ipairs(game.Workspace.Rooms:GetChildren()) do
local Table = {}
for i, Points in ipairs(Room:FindFirstChild("RushPoints"):GetChildren()) do
table.insert(Table,Points)
end
for i, Point in ipairs(Table) do
TweenService:Create(Torso,TweenInfo.new(.5),{CFrame = Point.CFrame}):Play()
print(Point.Name)
wait(.5)
end
end
Not enough information here … I’ll take a guess. See if a sort works.
for _, Room in ipairs(game.Workspace.Rooms:GetChildren()) do
local Table = {}
for _, Points in ipairs(Room:FindFirstChild("RushPoints"):GetChildren()) do
table.insert(Table, Points)
end
table.sort(Table, function(a, b) return a.Name < b.Name end)
for _, Point in ipairs(Table) do
TweenService:Create(Torso, TweenInfo.new(.5), { CFrame = Point.CFrame }):Play()
print(Point.Name)
wait(.5)
end
end
May not be ipairs also. Just a guess. Think the sort is all you really need.
local RoomsFolder = workspace.Rooms
local Rooms = RoomsFolder:GetChildren()
table.sort(Rooms, function(Left, Right)
return tonumber(Left.Name) < tonumber(Right.Name)
end)
for _, Room in ipairs(Rooms) do
local PointsFolder = Room.RushPoints
local Points = PointsFolder:GetChildren()
table.sort(Points, function(Left, Right)
return tonumber(Left.Name) < tonumber(Right.Name)
end)
for _, Point in ipairs(Points) do
local Tween = TweenService:Create(Torso, TweenInfo.new(0.5), {CFrame = Point.CFrame})
Tween:Play()
Tween.Completed:Wait()
end
end