WeldConstraint doesnt seem to be working


my code that is tweening the main part that the other two parts are welding too:

workspace.Obby.Stage8.activation3.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and stage8["sbeve3CanMove"] and hit.Parent:FindFirstChild("Humanoid").Health > 0 then
		stage8["sbeve3CanMove"] = false
		local UFO = game.ReplicatedStorage.Assets.UFO:Clone()
		UFO.Parent = workspace
		local CylinderSize = UFO.Part.Size
		UFO.Part.Size = Vector3.new(UFO.Part.Size, 1, UFO.Part.Size)
		local tween = ts:Create(UFO.MeshPart, TweenInfo.new(5), {Position = workspace.Obby.Stage8.UFOPoint.Position})
		tween:Play()
		tween.Completed:Connect(function()
			UFO.Part.Transparency = 0.3
			local tween1 = ts:Create(UFO.Part, TweenInfo.new(3), {Size = Vector3.new(UFO.Part.Size, CylinderSize.Y, UFO.Part.Size)})
			tween1:Play()
			tween1.Completed:Connect(function()
				task.wait(3.5)
				UFO:Destroy()
			end)
		end)
		UFO.Part.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") and stage8["sbeve3CanMove"] and hit.Parent:FindFirstChild("Humanoid").Health > 0 then
				local hrp = hit.Parent:FindFirstChild("HumanoidRootPart")
				local align = Instance.new("AlignPosition", hrp)
				align.Attachment0 = hrp.RootAttachment
				align.Attachment1 = UFO.Union.Attachment
				align.Responsiveness = 5
				task.delay(2.5, function()
					hrp.Parent:FindFirstChild("Humanoid").Health = 0
				end)
			end
		end)
	end
end)

btw yes the main part is anchored and the others arent

Welds get modified when the Position or Orientation properties are modified. To tween stuff connected by welds without changing the welds you’ll need to tween the CFrame property instead.

So, for your code, change this line:

local tween = ts:Create(UFO.MeshPart, TweenInfo.new(5), {Position = workspace.Obby.Stage8.UFOPoint.Position})

to

local currentCFrame = UFO.MeshPart.CFrame
local goalPosition = workspace.Obby.Stage8.UFOPoint.Position
local goalCFrame = currentCFrame - currentCFrame.Position + goalPosition
local tween = ts:Create(UFO.MeshPart, TweenInfo.new(5), {CFrame = goalCFrame})

Here is a bit of the docs about this:


Repositioning Behavior

Moving a welded BasePart behaves differently depending on whether the part was moved through its Position or through its CFrame.

  • If a welded part’s Position is updated, that part will move but none of the connected parts will move with it. The weld will recalculate the offset from the other parts based on the moved part’s new position.

  • If a welded part’s CFrame is updated, that part will move and all of the connected parts will also move, ensuring they maintain the same offset as when the weld was created.


1 Like