I’m trying to union a bunch of parts together. However, as soon as UnionAsync() is called, the function breaks. No union is formed, nor does any code after UnionAsync() work at all. I am completely at a loss as to why this happens.
local function unionParts(player)
local Art_Folder = workspace:FindFirstChild("Art_Folder")
local Player_Folder = Art_Folder:FindFirstChild(player.Name.."_Art")
local toUnion = Player_Folder:GetChildren()
local mainPart = toUnion[1]:Clone()
mainPart.Parent = Art_Folder
print(toUnion)
local newUnion = mainPart:UnionAsync(toUnion, nil, Enum.RenderFidelity.Performance)
newUnion.Parent = Art_Folder
newUnion.CFrame = mainPart.CFrame
newUnion.Name = "Octagon"
mainPart:Destroy()
for i, v in pairs(toUnion) do
print("Destroying...")
v:Destroy()
end
end
Update: I started using GeometryService:UnionAsync, which lets the following code run, but doesn’t create a union. I even tried using a pcall() with it, and the pcall returned true, yet the union is nowhere to be found, even when parented to workspace.
UnionAsync() is an extremely resource heavy task and can take a quarter of a second to fully complete. Also I would recommend looking at the UnionAsync() documentation to make sure everything you have set up is correct.
local Art_Folder = workspace:FindFirstChild("Art_Folder")
local Player_Folder = Art_Folder:FindFirstChild(player.Name.."_Art")
local toUnion = {}
for i,v in pairs(Player_Folder:GetChildren()) do
table.insert(toUnion, v)
end
local mainPart = toUnion[1]:Clone()
mainPart.Parent = Art_Folder
print(toUnion)
local success, newUnion = pcall(function()
geo:UnionAsync(mainPart, toUnion)
end)
if success then
success.Parent = workspace
success.Position = mainPart.Position
success.Name = "NewUnion"
mainPart:Destroy()
for i, v in pairs(toUnion) do
print("Destroying...")
v:Destroy()
end
end
This is the code I have now. GeometryService:UnionAsync returns nil, even though the pcall returns success as true.
Editing the union inside the function itself allows me to change it’s properties, but trying to print any property like size or position always results in nil, so the union is just not being made