Excuse me, I am attempting to weld objects to an engine without them being touching, anyway to do that ( The objects are cframed and unanchored ) Please do not reply with any links concerning wiki.roblox or lualearners because I have tried both.
How do I weld two objects together without them touching?
4 answers
Here is an easy function to weld two objects exactly where they are (they will not touch):
function Weld(p1, p2)
local w = Instance.new("Weld", game.JointsService); -- create the weld and correctly store it in the JointsService
w.C1 = p1.CFrame:toObjectSpace(p2.CFrame)
w.Part0 = p2 -- Set the main part
w.Part1 = p1 -- Set the joined part
end
Weld(Workspace.Part1, Workspace.Part2) -- Call the function to weld the two objects
EDIT: What you're probably most confused about is this line:
w.C1 = p1.CFrame:toObjectSpace(p2.CFrame)
The C1 is the "negative push" away from where the parts are joined. So we want to make sure the two parts stay exactly where they are, right? Welds work in object-space coordinates (so do all joints). Remember that.
All this line does is set the part getting joined to be in the object-space of the second part. This way they will stay the same distance away from each other (in their object-space) when joined.
You can just use C0 and C1 like you would supposing that they were touching. If you want to weld two parts together in the exact manner they are currently, you can do this:
weld.C1=weld.Part1.CFrame:toObjectSpace(weld.Part0.CFrame)
What that will do is set the C1 what you need to have it look the same. Assume Part0 and Part1 are set already, and C0 is the default.
4 comments
It is not good practice to use this format of setting the C1 to the object-space of the main part for new work.
No I do not, I do not understand how to set that.
I've updated my answer accordingly and given your answer an upvote, as it is more complete.
How noble of you.
THANK YOU!!!!
1 comment
Please select an answer by clicking "Accept Answer" below the poster's avatar and not posting an "answer" to say thanks.
Instance.new("Weld")
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Could you possible break that down using comments ( IGN comments after each line ) I am not quite the best at understanding things.
Sure; but if you really want to understand how they work, you will need to learn about the concepts of world-spaces and object-spaces.