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

How can i move a welded parts position?

Whenever I weld apart, it moves to a random position. How can I move it and rotate it etc.? When I weld it just moves to a random position and I can't move it without the weld breaking. I am using a weld constraint not a script. I would love it if you could help.

1 comment

0

Where would i place the script?

1 answer

Welds have two CFrame which are able to control offset/rotation of the weld, called C0 and C1. When you create a weld, these two offset values are both initially CFrame.new(0,0,0). This means that the two welded parts will end up on top of each other.

If when you weld, you want to keep the parts positioned where they were originally, you can use CFrame:inverse() for C0 and C1, as follows

local a = game.Workspace.PartA
local b = game.Workspace.PartB

local w = Instance.new("Weld")
w.Part0 = a
w.Part1 = b
w.C0 = a.CFrame:inverse()
w.C1 = b.CFrame:inverse()
w.Parent = game.Workspace

Hope this helps, happy coding :)

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