Is there a way to make a script that will register all the parts in your workspace and weld them to other touching parts on command?
I'm hoping to make a script on this but I don't know if the studio would fully support this and I would appreciate any insight on this. Currently, I am making a survival game that is round based so i need a way to reconnect and reweld all parts, the problem is I'm using terrain. Currently, I am using a script that will join parts together with a line of code for every part. The problem is this takes a very long time, this is the script for one tree
there are about a hundred weld lines but I didnt want to fill the page with that much code
local debounce = true local treeReset = game.Workspace.TreeReset while true do if treeReset then if debounce then debounce = false local function weldBetween(a, b) --Make a new Weld and Parent it to a. local weld = Instance.new("ManualWeld", a) --Get the CFrame of b relative to a. weld.C0 = a.CFrame:inverse() * b.CFrame --Set the Part0 and Part1 properties respectively weld.Part0 = a weld.Part1 = b --Return the reference to the weld so that you can change it later. return weld end
local weldOne = weldBetween(script.Parent.Part1, script.Parent.Part2) local weldTwo = weldBetween(script.Parent.Part2, script.Parent.Part3) local weldThree = weldBetween(script.Parent.Part3, script.Parent.Part4) local weldFour = weldBetween(script.Parent.Part4, script.Parent.Part5) local weldFive = weldBetween(script.Parent.Part5, script.Parent.Part6)