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

Welding Non Touching Bricks

I am currently making a truck which has parts that have been Cframed at angles. However I can not use the roblox studio weld tool as that only works when parts are at right angle or in the same direction. I know there is a way to script a weld for bricks that don't touch. I tried this and I didn't work:

weldBetween(Script.Parent.Part1, Script.Parent.Part2)

I have used Script.Parent and the model of truck changes places in the workspace regularly.

Any help would be much appreciated.

1 answer

weldBetween() is NOT a function and welds do not work in this way. Welds are objects that must be created through Instance.new(). The parts must be set through Part0 and Part1. C0 and C1 are the offsets of the weld which you will most likely need to use if you want the model to stay in the same position.

For example:

local weld = Instance.new("Weld", game.Workspace) -- Creates a new weld
weld.Part0 = script.Parent.Part1 -- Sets the primary part
weld.Part1 = script.Parent.Part2 -- Sets the secondary part
weld.C0 = CFrame.new(0,0,0) -- Offset of the weld

However one weld only works for holding two parts together so I suggest using a loop for the length of the model you are welding:

for _,v in pairs(game.Workspace["MODELNAME"]:GetChildren()) do
local we...
end

For more information about welds: http://wiki.roblox.com/index.php/RBX.lua.Weld_(Object)

(Tags aren't right)

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