How would i move parts inside a part?

i want to move parts inside a part along with the parent
Screenshot 2023-07-13 at 3.34.07 PM
when change position of table, the mesh and the thing dosn’t move with it. any ideas?

1 Like

Weld the MeshPart and Thing to Table

Screenshot 2023-07-13 at 3.38.28 PM
didn’t work, did i do it wrong?

I assume you mean in-game movement, if so there’re 2 solutions:

Solution 1: Non-physics-based movement
If you plan to move the parts using a script, then you should create a model above the Table(by clicking the table in explorer, “Group as a Model”) and use the following code to move it:

local Table = workspace:WaitForChild("Table") --where Table is the model not the part!

local r = math.rad --converts degrees to radians for the function below
local pos = CFrame.new(10, 2, 20) --where you want it to be?
local angle = CFrame.Angles(r(90), r(0), r(0)) --the inputs of r are degrees

Table:PivotTo(pos*angle) --move the object to that pos and orientation

Solution 2: Physics-based movement
If you plan to move parts through physics, for example using modifiers, velocities, pushing them etc then you need to weld them to each other, here’s a welding script that welds the parts to the parent:

function weld(p: Instance)
	local parts: {Instance} = p:GetDescendants()
	local part0
	local welds = Instance.new("Folder", p)
	welds.Name = "Welds"
	for _, part1 in pairs(parts) do
		if not part1:IsA("BasePart") then continue end
		if not part0 then part0 = part1 continue end
		local weld = Instance.new("WeldConstraint")
		weld.Part0 = part0
		weld.Part1 = part1 
		weld.Name = part1.Name
		weld.Parent = welds 
	end
end

weld(workspace) --welds all objects
2 Likes

When using the WeldConstraint you also need an attachment. Check out the WeldConstraint docs here to write some code or create it in the explorer. Also make sure the parts are un-anchored. Applying the massless property can be useful if you are moving the parent with a force.

1 Like

When you create the welds are you doing it with your script, or are you just trying to move the Table (and children) with your script?

In your second post you have WeldConstraints there, but how did you create them? If you use the Constraints tools in the Model tab in Studio you can choose one Part, click the Weld Constraint tool, then click the other Part to create the Weld.
In the WeldConstraints tools tab there’s also a checkbox for Show Welds. This will show active welds between 2 Parts as a green line and inactive welds as a gray line.
When you click on the green line or select the WeldConstraint in the Explorer window both the joined Parts should have a green SelectionBox around them. If there is no line or the SelectionBoxes don’t light up then you haven’t selected the Part0 and Part1 of the weld correctly.