I'm making a script where if 2 parts welded together touch a specific part, it will destroy the weld within the two welded parts...

the script works (destroys weld) but always outputs an error: https://gyazo.com/ee3fd24e54e0ef8f041de6244e075f6d

the code inside the part being touched by the two welded parts:

return function()
	script.Parent.Touched:Connect(function(t)
		if t.Name == "Pushbox" and t.Parent.ClassName == "Part" then
			t.WeldConstraint:Destroy()
		end
	end)
end

What the model of the two welded parts look like: https://gyazo.com/89d332e700af3b77b9f68b5145b6183a

note: if the pushbox isnt inside the other pushbox, it wouldn't work properly with the spawning script

I've been going at this for about an hour trying to figure out how to make it work without outputting an error, any answers are appreciated.

1 comment

0

You could just pcall() it so its as if it never errored to begin with...