How do I create welded parts?

I’m having a problem In my welding game, and basically what happens is when i create a part, with weld on all surfaces through a script, it does not weld to the base, or anything else, I have tried waiting a little before unanchoring it, but still does not help… This is the server script
local remote = game:GetService(“ReplicatedStorage”):WaitForChild(“Add”)

remote.OnServerEvent:Connect(function(player,Name,CanCollide,Material,BrickC,Size,Pos)
	local part = Instance.new("Part")
	part.Name = Name
	part.Position = Pos
	part.CanCollide = true
	part.Material = Material
	part.BrickColor = BrickC
	part.Size = Size
	part.TopSurface = "Weld"
	part.BackSurface = "Weld"
	part.RightSurface = "Weld"
	part.LeftSurface = "Weld"
	part.FrontSurface = "Weld"
	part.Anchored = true
	part.Parent = workspace.ActiveParts[player.Name.."'s Parts"]
	wait(.1) -- wait 1 milisecond to unanchor, but still does not help
	part.Anchored = false
end)

Thanks for any suggestion :p

1 Like

You can create weld instances manually through script.

Either using Weld or WeldConstraint and setting Part0 on the part while Part1 could be the neighboring part. Raycast could detect neighboring parts, I think.

Example

local weld = Instance.new("WeldConstraint")
weld.Part0 = part
weld.Part1 = otherPart
weld.Parent = part
1 Like

It can but it’s a full sandbox game and i would need more than 1 weld constraint to weld with all neighboring parts around, but would probably be too laggy with many parts (which can also be resized), and I don’t even know how to do that, I know theres a simpler way, like how stamper tool used to work, It always properly welded unanchored parts…

I fully doubt too many welds would lag. Traditional welding was technically the same as the code sample I sent, only exception of WeldConstraint being Weld instead.

I still don’t know how to do that, theres some kind of weld called Part-to-strong-joint sometimes made when you attach 2 parts with weld in studio, but for some reason does not create when I place the parts

The Part-To-Strong-Joint is the traditional Weld but named. Placing them through script does not create automatic welding. The auto-welding worked when you enabled something in Studio that allowed welding while dragging the parts.

There’s more that’s involved if you choose to use non-smooth surfaces in order to create joints. Not typically the best way to go about this though. JointInstances, specifically Welds and WeldConstraints, are what you’re looking for if you want to weld something to another.

Frankly though, your code doesn’t look like it’s that simple for part-to-part welding. Could you explain your use case? This doesn’t look like a scenario where you’re looking to create welded parts but perhaps something else, such as anchored parts.

With the above in mind, a quick skim does reveal that you are using anchored parts. It must be said that welding does not work with anchored parts, as the anchorship takes precedence over the weld. Welding anchored parts is pointless, it does nothing.

I made it anchor the parts and unanchor them after a small amount of time to make sure everything would weld, but all I just needed was :MakeJoints(), now everything works.

By the way, just for the future, that’s not 1 millisecond, I think it’s 100, cos 1000 milliseconds make up a second :+1:

Edit: Oh my, 2 years, I didnt realize how long ago thus post was