Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to make a script that joins all the parts of your game?

Asked by
BRAEGON -8
4 years ago

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)

0
Yes. Use a RemoteEvent from client to server. DeceptiveCaster 3761 — 4y
0
Would that work for rewelding all the parts? I want this to be server run if possible, I dont really see how other people having this kind of control would help. Im interested in your idea though BRAEGON -8 — 4y
0
If you're doing a chat command, have a LocalScript handle the message and let the server handle the welds. DeceptiveCaster 3761 — 4y
0
thank you, Im not trying to use a chat command though, the goal is to have this running every round of the game BRAEGON -8 — 4y
View all comments (3 more)
0
Maybe you gane use BasePart:GetTouchingParts() and weld it like that, but ive herd it may lag Fad99 286 — 4y
0
Trying to write a script with this, would you mind showing an example of how you would use this to weld the parts? I understand the use of finding the parts but Im looking all of the internet for how to apply it BRAEGON -8 — 4y

Answer this question