the script below should unanchor all parts of the parent parent group. so script.parent.parent, while also emitting some effects for destruction effects. though it used to work, now it literally unanchors the whole game making it lag immensely. instead of just unanchoring one group model
local ready = true
local sound = script.Parent.Sound--Change to your sound location.
local delaytime = 5
script.Parent.Touched:Connect(function()
if ready == true then
ready = false
for i, v in pairs(script.Parent.Parent:GetChildren()) do
if not v:IsA("BasePart") then continue end
v.Anchored = false
local smoke = Instance.new("Smoke")
smoke.Parent = v
smoke.Color = Color3.new(197, 196, 199)
smoke.Opacity = 0.25
smoke.RiseVelocity = 6
end
sound:Stop()
sound:Play()
wait(delaytime) -- Amount of till making smoke dissapear
for i, v in pairs(script.Parent.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Smoke:Destroy()
end
end
script:Destroy()
ready = true
end
end)
That’s odd, I copied your script and did you what you did, put the sound and script in a part, modeled all the parts needed and tested it, it only unachored the parts in the model,
I believe I know why, the for loop iterates over everything one time, meaning that once all of the parts are destroyed, it’s an empty model. You can check if the model is empty, then you can disconnect the event and delete the model.
Is that script originally parented inside of that part? Or is it added into the part through another script. If so it should be disabled before cloning it into there.
just to clearify, there are multiple parts like these put together to create a building together. its basically a building and if you touch it it collapses
Then it’s not an issue with the script, you must’ve misplaced one. Use the explorer to search for all the destruct scripts and find one that is wrongly parented