Every time I input a table to the selection using game.Selection:Set(table), that table is later sorted somehow when trying to get the selection using game.Selection:Get(), making selection order impossible to determine. Normally, when you select something, the first part that you selected will always appear first in the table returned by game.Selection:Get()
However, whenever you input a table using game.Selection:Set(), that table is then automatically sorted (alphabetically, I presume?). I am using a lot of plugin features that rely on selection order, and use a scripted selection system that tries to keep the selection order using game.Selection:Set().
Repro code (command line):
local p1 = Instance.new("Part")
p1.Name = "p1"
p1.Parent = game.Workspace
local p2 = Instance.new("Part")
p2.Name = "p2"
p2.Parent = game.Workspace
local selectionTable1 = {p1, p2}
game.Selection:Set(selectionTable1)
print("selectionTable1 -> {")
for i,v in ipairs(game.Selection:Get()) do
print("[" .. i .. "] = " .. v.Name)
end
print("}")
local selectionTable2 = {p2, p1}
game.Selection:Set(selectionTable1)
print("selectionTable2 -> {")
for i,v in ipairs(game.Selection:Get()) do
print("[" .. i .. "] = " .. v.Name)
end
print("}")
p1:Destroy()
p2:Destroy()
edit: looks I made a typo on this repro code; however, it looks like this problem is being solved.
selectionTable1 should make p1 selected first, then p2 selected second. From what I’ve tested, this shows exactly as intended in the output.
However, selectionTable2 should put p2 first, and p1 second. What you’ll find is that the output will show the same order both times, even though the tables input to game.Selection:Set() are reversed.
I too am noticing some changes in studio selection behavior In one case I’m seeing (by hooking into Selection.SelectionChanged) the selection replaced shortly after setting it (through Selection.Set), with a selection that includes previously selected parts. I disabled all plugins in case one of them was manipulating the selection, but that did not seem to be the case. Currently working around this issue by adding a Wait() between two consecutive calls to Selection:Set() (otherwise, as described above, the items begin to stack up somehow). The tables passed in the calls to Selection.Set are new and only contain one item completely independent of the current selection, which makes me consider the possibility that this is a Studio bug, since it only began happening around July 13-14?
(Posted this in this thread since these issues are probably related to the same changes)
Also, it looks like this is really messing up with CSG operations. Since CSG operations rely on selection order, I can’t get a union to face the right direction and for textures to align correctly.
I’m not sure how these selections are ordered. It seems to be sorted by the same order it appears on Explorer, which is why the negative union operations are always selected first. My temporary fix is to use a negative union operation named “Aaron Aaronson” that is moved outside of the space that the intended CSG object should take.
I am still having texture alignment problems that way, though. It would be nice if I could select the non-negative part first.
edit: Making the negative part the exact size as the main part and messing with its offset from that part seems to work.
local selectionTable2 = {p2, p1}
game.Selection:Set(selectionTable1)
Made it a little tricky to test this until I found it! I’m working on getting the selection order fixed, as well as the other selection wonkiness that has been around for a few weeks.