Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

InstaWeld with Unions?

How can I make this work for Unions so not only parts will be welded?

local prev 
local parts = script.Parent:GetChildren() 
for i = 1,#parts do 
	if (parts[i].className == "Part") then 
		if parts[i].Name ~= "Part" then
		if (prev ~= nil)then 
			local weld = Instance.new("Weld") 
			weld.Part0 = prev 
			weld.Part1 = parts[i] 
			weld.C0 = prev.CFrame:inverse() 
			weld.C1 = parts[i].CFrame:inverse() 
			weld.Parent = prev
		end 
		prev = parts[i] 
		end
	end 
end
for i = 1,#parts do 
	if (parts[i].className == "Part") then 
		if parts[i].Name == "Left Leg" or parts[i].Name == "Right Leg" then
			parts[i].CanCollide = true
		end
		if parts[i].Name ~= "Part" then
				parts[i].Anchored = false 
				end
	end
end

1 answer

In order to get this to work, you just need to check if the parts are BaseParts or UnionOperations (The ClassName for Unions).

The following would replace lines 4 and 19 in your code block:

if (parts[i].ClassName == "BasePart") or (parts[i].ClassName == "UnionOperation") then

2 comments

0

Still not working

0

Does it weld normal parts?

This discussion is preserved as it was. New answers, comments, and votes are closed.