In this script, it runs a detection loop to see whether different bricks have a weld, or if their weld is broken. The problem is that it creates a sort of domino effect, that gets sent through the whole build since the deleted blocks get destroyed, causing the weld to become inactive.
is there anyway of moving around this problem? I cant think of a way to assign a variable to the blown up parts, then checking if the weld is attached to those. Any help is appreciated
local runservice = game:GetService("RunService")
local ifweld = script.Parent
local function WeldFinder()
for i,parts in pairs(ifweld:children()) do
if not parts:FindFirstChild("NAAP_Weld") then
if parts.Name == "NAAP_PrimaryPart" or parts.Name == "WeldHandler" then
-- Leave blank
else
while parts.Transparency <= 1 do
parts.Transparency += 0.05
task.wait(1)
end
if parts.Transparency >= 1 then
parts:Destroy()
task.wait(0.1)
end
end
else
if parts.NAAP_Weld.Active == false then
while parts.Transparency <= 1 do
parts.Transparency += 0.05
task.wait(1)
end
if parts.Transparency >= 1 then
parts:Destroy()
task.wait(0.1)
end
end
end
end
end
runservice.Heartbeat:Connect(function()
WeldFinder()
end)
would this also work for the parts that havent been directly blown up, but have broken welds?
EX:
if parts.NAAP_Weld.Active == false then
while parts.Transparency <= 1 do
parts.Transparency += 0.05
task.wait(1)
end
if parts.Transparency >= 1 then
parts:Destroy()
task.wait(0.1)
end
end
I think I would just use an event listener so it takes care of itself.
Something like:
for _, weld in pairs (MyBlocks:GetDescendants()) do
if weld:IsA("Weld") then
weld.Active.Changed:Connect(function()
-- you know it has changed
end)
end
end