Scripting Unions not working

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to union all of the parts in a model together, and have many models. The code will be run as a command.
  2. What is the issue? Include screenshots / videos if possible!
    I have written code that should definitely work, yet it does not union anything and does not throw any errors.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Here is my code:
for i,v in pairs(workspace.Model:GetChildren()) do
	local others = {}
	local basepart = nil
	for j,w in pairs(v:GetChildren()) do
		if j == 1 then
			basepart = w
		else
			table.insert(others,w)
		end
	end
	local newU = basepart:UnionAsync(others)
end

I am aware that UnionAsync is a working function, but I cannot get it working. I have tried running this code in a script and nothing happens there either.
Any help appreciated!

Fixed it:

for i,v in pairs(workspace.Model:GetChildren()) do
	local others = {}
	local basepart = nil
	for j,w in pairs(v:GetChildren()) do
		if j == 1 then
			basepart = w
		else
			table.insert(others,w)
		end
	end
	print(basepart)
	print(others)
	local newU = basepart:UnionAsync(others)
	newU.Parent = workspace
end

Just had to tell the union it needed to be parented to workspace or a descendent of it and it appears

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.