All seating is numbered as such:
The number is the row, and the letter is the chair.
For example, Row 1, Seat A, would be 1A.
I want to the camera to cycle through in order. Once it cycles through a whole row alphabetically, it goes the the next row, starting at A.
eg.
1A, 1B, 1C, 2A, 2B, 2C.
And when it comes to positioning the camera, could I use an attachment, instead of an invisible part, so that the camera knows where to tween to for each seat?
You can iterate through the rows and columns and use the utf8 library to get each letter.
for r = 1, 3 do -- Rows: Loops for the number of rows you have (in this case three)
for c = 0, 25 do -- Columns: Loops to get each letter
local letter = utf8.char(65+c) -- Gets the letter from unicode
local seat = game.Workspace:WaitForChild(r..letter)
-- All your tweening code below here
end
end
local Workspace = workspace
local function GetNextSeat(CurrentSeat) --Reference to the current seat.
local Row = string.match(CurrentSeat.Name, "^%d+") --Get row number from seat's name.
local Column = string.match(CurrentSeat.Name, "%u+$") --Get column letter from seat's name.
local Name = if Column == "Z" then (Row + 1).."A" else (Row)..string.char(string.byte(Column) + 1) --Get the next seat's name.
local NextSeat = Workspace:FindFirstChild(Name) --Find the next seat.
return NextSeat --Either 'nil' (if seat not found) or a reference to the next seat (if seat is found).
end
Would be more performant to have a getter function (as opposed to running a nested loop each time).