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!
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!
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.
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)
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:
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
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?
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