Moving Primary Part CFrame with Welds doesn't move with Welded Parts

Hello Developers,

I am trying to move a Group/Model with Welds and CFrame. But the problem is, only the Primary Part moves but not the reset of the welded parts.

Code

(Code is placed in a Module Script inside of a Function on the Server.)

local NewBooth = Booths.PreCreated.GenericBoothFolder.GenericBooth:Clone()
local NewBoothSign = Booths.PreCreated.GenericBoothFolder.BoothSign:Clone()
local NewOwnerSign = Booths.PreCreated.GenericBoothFolder.OwnerSign:Clone()

local BoothUIFolder = Instance.new("Folder")
BoothUIFolder.Name = Player.Name.."_BoothUI"
BoothUIFolder.Parent = StarterGui.Booths

NewBooth.PrimaryPart = NewBooth.BoothPath.Base

for _, Model: Model in pairs(NewBooth:GetChildren()) do
	for a, Part: Part in pairs(Model:GetChildren()) do
		if Part.Name ~= "Base" then
			print("Created New Weld!")
			local NewWeld = Instance.new("WeldConstraint")
			NewWeld.Parent = Part
			NewWeld.Part0 = NewBooth.BoothPath.Base
			NewWeld.Part1 = Part
		end
	end
end

NewBooth.Name = Player.Name.."_Booth"
NewBooth.Parent = BoothArea
NewBooth.PrimaryPart.CFrame = CFrame.new(BoothArea.CFrame.X, 13.8, BoothArea.CFrame.Z)

And yes, print("Created New Weld!) does print.

Update: I was able to solve my issue. I used MoveTo() and PivotTo().

Here’s my updated code of anyone needs it.

	local NewBooth = Booths.PreCreated.GenericBoothFolder.GenericBooth:Clone()
	local NewBoothSign = Booths.PreCreated.GenericBoothFolder.BoothSign:Clone()
	local NewOwnerSign = Booths.PreCreated.GenericBoothFolder.OwnerSign:Clone()
	
	local BoothUIFolder = Instance.new("Folder")
	BoothUIFolder.Name = Player.Name.."_BoothUI"
	BoothUIFolder.Parent = StarterGui.Booths
	
	NewBooth.PrimaryPart = NewBooth.BoothPath.Base
	
	for _, Model: Model in pairs(NewBooth:GetChildren()) do
		for a, Part: Part in pairs(Model:GetChildren()) do
			if Part.Name ~= "Base" then
				print("Created New Weld!", Part.Name)
				local NewWeld = Instance.new("WeldConstraint")
				NewWeld.Parent = Part
				NewWeld.Part0 = NewBooth.BoothPath.Base
				NewWeld.Part1 = Part
			end
		end
	end
	
	NewBooth.Name = Player.Name.."_Booth"
	NewBooth.Parent = BoothArea
	NewBooth:MoveTo(Vector3.new(BoothArea.Position.X, 13.8, BoothArea.Position.Z))
	NewBooth.PrimaryPart.CFrame = CFrame.new(BoothArea.CFrame.X, 13.8, BoothArea.CFrame.Z)
	
	local newCF = NewBooth:GetPivot() * CFrame.Angles(0, math.rad(180), 0) -- Rotate by 180 deg around the Y axis
	NewBooth:PivotTo(newCF)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.