WeldBreaking Laser not breaking welds on unanchored parts welded to anchored parts

Obligatory disclaimer, all of the following has been generated using AI, so forgive my lack of knowledge or terrible terminology when it comes to scripting. Both the model and script are included below.

I’m trying to create a moving sphere that fires a laser with weld-removal properties, however it only seems to work on models that aren’t welded/jointed on anchored pieces. I’ve tried changing their CanTouch/CanCollide settings, re-sized the laser to larger proportions so it could encompass entire buildings, switched from the script spawning its own laser to manually adding one with a modified pivot in its model, all to no effect.

All destructible structures are only held by welds, unanchored, and don’t have any unions in them. I’ve also initially set up a CollisionGroup for the sphere itself not to collide with destructible environment, though this doesn’t seem to be related as reversing it made no difference.

Any and all thoughts would be greatly appreciated.

WeldKnockingIssue.wmv (4.9 MB)

-- WeldKnockerScript
local CollectionService = game:GetService("CollectionService")

local model = script.Parent
local body = model:WaitForChild("Body")  -- The sphere base part

-- Weld removal, knockback, and kill

local function onPartTouched(selfPart: BasePart, hitPart: BasePart)
	if not hitPart or not hitPart.Parent then
		return
	end

	-- 1) Remove welds from the touched part
	for _, weld in ipairs(hitPart:GetDescendants()) do
		if weld:IsA("WeldConstraint") or weld:IsA("Weld") then
			weld:Destroy()
			print("Destroyed weld:", weld.Name, "in", hitPart:GetFullName())
		end
	end

	-- 2) Break joints (e.g. player limbs, unanchored parts)
	hitPart:BreakJoints()

	-- 3) Apply knockback
	local direction = (hitPart.Position - selfPart.Position).Unit
	hitPart.AssemblyLinearVelocity = direction * -100

	-- 4) Kill the player if it's part of a character
	local hitCharacter = hitPart.Parent
	local hitHumanoid = hitCharacter:FindFirstChildOfClass("Humanoid")
	if hitHumanoid then
		hitHumanoid.Health = 0
	end
end


-- 1) SPHERE (BODY) Touched

if body:IsA("BasePart") then
	body.Touched:Connect(function(hit)
		onPartTouched(body, hit)
	end)
end

-- 2) LASER PART: Wait for spawn, then connect Touched

model.ChildAdded:Connect(function(child)
	-- We assume the laser part is named "LaserPart"
	if child:IsA("BasePart") and child.Name == "LaserPart" then
		child.Touched:Connect(function(hit)
			onPartTouched(child, hit)
		end)
	end
end)

Laser Sphere - Creator Store

Laser Sphere - Creator Store

did you try configuring the anchored property on parts it hits, to force them to become unanchored?

It seems the only way for the unanchored parts to lose their welds is having no anchored parts welded anywhere to it, which is rather problematic (and violently shaky) after a single sweep.

The crane’s anchor part is held by a simple weld and attachment instead of a WeldConstraint, though. If I can’t solve the script I might be able to re-design the building’s baseplates instead. It doesn’t explain why I don’t have this same issue on other entities on my project, though.

Managed to solve it by adding an explosive element to the script.

local function destroyWeldsAndExplode(part)
	if not part or not part:IsA("BasePart") then return end

	local groupName = PhysicsService:GetCollisionGroupName(part.CollisionGroupId)
	if groupName == "Debris" then
		print("Destroying welds on Debris part: " .. part:GetFullName())
		for _, weld in ipairs(part:GetDescendants()) do
			if weld:IsA("WeldConstraint") or weld:IsA("Weld") then
				weld:Destroy()
				print("Destroyed weld: " .. weld.Name)
			end
		end

		-- Create an explosion at the part's position
		local explosion = Instance.new("Explosion")
		explosion.Position = part.Position
		explosion.BlastPressure = 5000   -- adjust as needed
		explosion.BlastRadius = 10         -- adjust as needed
		explosion.DestroyJointRadiusPercent = 10  -- prevents auto-destruction of joints
		explosion.Parent = workspace

		-- 50% chance to destroy the struck part (for performance)
		if math.random() < 0.5 then
			part:Destroy()
			print("Struck part destroyed for performance.")
		end
	end
end

Now it behaves like a deadly laser.

Laser Sphere - Creator Store

1 Like