Why is BreakJoints not working When Primary Part is hit

I’m trying to make it so when the Tsunami wave touches any destructible building it will break all the welds that hold the building together so the building falls apart!

For some reason its not breaking the welds when Tsunami hits the building it only works if there’s an NPC within the model
https://i.gyazo.com/1b114a8a3360681a2c9f198d19a2cd4d.mp4


You can see below that all other buildings are still welded but the Convenience Store is gone since it has a NPC in it

This is without the NPC in it vVVVv
https://i.gyazo.com/2c96ef2e4da67cfe79eab8723e8cb339.mp4

This used to work perfectly fine Idk if this is a Bug from Roblox… I’ve tried changing the names of the parts in the script and nothing works all I know is that it has something to do with the NPC…

Tsunami Destruction script which is inside the Tsunami Wave Part vVv

script.Parent.Touched:Connect(function(hit)
	if hit.Name == "Primary" or "Primary2" or "Primary3" or "Primary4" or "Primary5" or "Primary6" or "Primary7" or "Primary8" then
		
		hit:BreakJoints()
	end
end)

All Parts are Welded to there Primary Part so when the tsunami hits/touches the Primary parts then all its connecting Welds will break!
image

1 Like

Are you using weld constraints or just normal/deprecated welds? And i’m guessing that there are more parts than just the Primary’s inside the individual ModelMaps.

1 Like

image
Weld Constraints

1 Like

Yes there are more Parts besides the Primarys in each Model

1 Like

I see, what you could do instead of using breakjoints() is a for loop:

example:


script.Parent.Touched:Connect(function(hit)
	if hit.Name == "Primary" or "Primary2" or "Primary3" or "Primary4" or "Primary5" or "Primary6" or "Primary7" or "Primary8" then
		
              for _, p in pairs(hit.Parent:GetChildren()) do
                     if p:FindFirstChildOfClass("WeldConstraint") then
                           p:FindFirstChildOfClass("WeldConstraint"):Destroy()
                     end
              end
	end
end)
1 Like

It still isn’t working I put a Print under the if hit.Name == “Primary” or… line and its not showing in the Output when Tsunami hits…

Well, instead of if hit.Name == "Primary" or "Primary2" or "Primary3" or "Primary4" or "Primary5" or "Primary6" or "Primary7" or "Primary8" then replace the whole if statement with:

if hit.Name:lower():match("primary") then

Also, is this script placed inside the Tsunami

yes its inside the Tsunami Wave Part

Alright, then replace the if statement with the If statement i provided
and see if that works

still not working and not printing in the output

Try this, and if this doesn’t work could i see the script?

local function on_touched(hit)
    print(hit.Name)
	if hit.Name:lower():match("primary")  then
		
              for _, p in pairs(hit.Parent:GetChildren()) do
                     if p:FindFirstChildOfClass("WeldConstraint") then
                           p:FindFirstChildOfClass("WeldConstraint"):Destroy()
                     end
              end
	end
end)

script.Parent.Touched:Connect(on_touched)

‘’’
local function on_touched(hit)
print(hit.Name)
if hit.Name:lower():match(“primary”) then

	for _, p in pairs(hit.Parent:GetChildren()) do
		if p:FindFirstChildOfClass("WeldConstraint") then
			p:FindFirstChildOfClass("WeldConstraint"):Destroy()
		end
	end
end

end

script.Parent.Touched:Connect(on_touched)
‘’’
Ill get the weld script to it also works but ill add it here just in case

--BrickBuilding1
local modelBB1 = workspace["Coastal Map"].BrickBuilding1
local primary2 = modelBB1.PrimaryPart

for i, part in pairs(modelBB1:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary2) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary2
	end
end
--WoodBuilding1
local modelWB1 = workspace["Coastal Map"].WoodBuilding1
local primary3 = modelWB1.PrimaryPart

for i, part in pairs(modelWB1:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary3) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary3
	end
end
--ConvienianceStore1
local modelCS1 = workspace["Coastal Map"].ConvienianceStore1
local primary4 = modelCS1.PrimaryPart

for i, part in pairs(modelCS1:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary4) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary4
	end
end
--GasStation1
local modelGS1 = workspace["Coastal Map"].Gasstation
local primary5 = modelGS1.PrimaryPart

for i, part in pairs(modelGS1:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary5) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary5
	end
end
--House1
local modelH1 = workspace["Coastal Map"].House1
local primary6 = modelH1.PrimaryPart

for i, part in pairs(modelH1:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary6) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary6
	end
end
--House2
local modelH2 = workspace["Coastal Map"].House2
local primary7 = modelH2.PrimaryPart

for i, part in pairs(modelH2:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary7) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary7
	end
end
--Bridge
local modelB = workspace["Coastal Map"].Bridge
local primary8 = modelB.PrimaryPart

for i, part in pairs(modelB:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary8) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary8
	end
end
--BeachDecorations
local modelBD = workspace["Coastal Map"].Beachdeco
local primary9 = modelBD.PrimaryPart

for i, part in pairs(modelBD:GetChildren()) do
	if part:IsA("BasePart") and (part ~= primary9) then
		local weld = Instance.new("WeldConstraint",part)
		weld.Part0 = part
		weld.Part1 = primary9
	end
end

Weird… I just tested out my script and recreated your situation and it seem too be printing out the part name and breaking the welds.

Also, it won’t even print out or even register the touched function?

nope it wont print or register function

and this used to work just fine about a year ago when I last worked on this game

Well. Can i see the whole Tsunami part in the explorer and it’s children? Maybe there is something wrong there perhaps. Is there more too the Tsunami script?

image

Is there a particular reason to specifically just checking if it’s a PrimaryPart and not if there is Weld inside a part and just Destroying it that way? Also, If you have canTouch setting off that may be the cause

cantouch is on and I just use Primarypart cause I thought it would be easier also when there’s an NPC in within the model but still in the workspace it gets destroyed when hit by the Tsunami