Weld CFrame is not working

Hi, the script below tells an unanchored part to weld to another part (anchored or not), the part’s collision is on and it doesn’t work. It is positioning itself at 0, 0, 0 in the world instead of what I’ve told it to.

				local weld = Instance.new("Weld")
				weld.Parent = Object
				weld.Part0 = Object
				weld.Part1 = hit
				weld.C0 = CFrame.new(mousePosition.p.X, (mousePosition.p.Y + 1), mousePosition.p.Z)

Please help,
Cheers,

1 Like

Just tried turning the collision off, it does nothing. mousePosition.p is not returning 0, 0, 0 so that shouldn’t be the problem.

1 Like

Is your hit and Object anchored by any chance? Is mousePosition the mouse.Hit or the mouse.Hit.p?

Show us the output and we could help you more

1 Like

Hi, mousePosition is mouse.Hit and the hit object is anchored but the object object is not.

1 Like

If it’s positioning itself at 0,0,0 then there is a problem when setting the position. Vector3.new and CFrame.new has the default position at 0,0,0

1 Like

Ok, to make it not complicated. Here is a simple set up:
The weld you see in the image’s below, Part0 is the parent of the weld already.

The code:

script.Parent.Weld.Part1 = script.Parent.BluePart
script.Parent.Weld.C1 = CFrame.new(script.Parent.BluePart.Position)

Image to before game is run:

Image after the game has run:

1 Like

You have to set both the C0 and C1 of the Weld | Roblox Creator Documentation.

Ok, what do I set C0 to? Thanks for the reply btw

1 Like

Well, like the link to weld I put in the previous post says, that’s the pivot point offset of where the weld sits.
part1.CFrame * C1 == Part0.CFrame * C0

I’ll try that, thanks for the reply again.

1 Like