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.
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.
THANK YOU!!!!