Unanchor on touch makes whole game unanchor

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)
1 Like

Could you provide explorer ancestroy screenshot including the script and children of script.Parent.Parent?

yes, remember that the amount of parts may change depending on what building i chose to screenshot, (this is the one i currently had trouble with)
image

You can use:

		for _, v in pairs(script.Parent.Parent:GetChildren()) do
			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

thank you, i will test it, but can you tell me what was wrong? i became mad bcs i couldnt figure it out
edit: i tested and it didnt work

Why are u adding if not basepart???

if not v:IsA("BasePart") then continue end

I don’t think that is necessary tbh
Or if you wanna avoid basepart here is the code!

for _, v in pairs(script.Parent.Parent:GetChildren()) do
			if not v:IsA("BasePart") then
			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
		end

Mark My post as a solution as it works! If you need more help dm me in discord! CallMeEvil#0001

Strange. Could you try printing each part as you unanchor it?

1 Like

i have no idea how i would do such thing

@kiri1234jojo Read my post! I edited it above!

for i, v in pairs(script.Parent.Parent:GetChildren()) do
			if not v:IsA("BasePart") then continue end
			v.Anchored = false -- here
			local smoke = Instance.new("Smoke")
			smoke.Parent = v
			smoke.Color = Color3.new(197, 196, 199)
			smoke.Opacity = 0.25
			smoke.RiseVelocity = 6
		end

on the line v.Anchored = false add print(v) directly before or after

@kiri1234jojo I have tested my code in my world and it works fine!

would it help if i tell you that it are multiple models touching eachother? idk what that would change but idk why this happens

no? wait add me in roblox. and add me to tc. different tc not ur real game.

1 Like

ill add u now, but lets do this later, im busy rn

Okay!.. I am gonna accept you soon.