Hi! I've tried to make a code where my snow block can auto regenerate when it's not full. However, the descendant removing function only works in studio, but not in game. I've looked for errors but nothing appears.
local CollectionService = game:GetService("CollectionService") local TaggedParts = CollectionService:GetTagged("SnowBlock") local respawnCooldown = 5 for i, v in pairs(TaggedParts) do v.DescendantRemoving:Connect(function(part) print(part) print("hii") if part.Name ~= "Part6" and part.Name ~= "SnowBlock" then part:WaitForChild("Value").Parent = v:FindFirstChild("Part".. tostring(tonumber(string.sub(part.Name,5)) + 1)) print("Part".. tostring(tonumber(string.sub(part.Name,5)) + 1)) end end) local function autoRespawn() while true do local backup = v:Clone() wait(respawnCooldown) for i, a in pairs(v:GetChildren()) do if a:FindFirstChild("Value") then if a.Name ~= "Part1" then backup.Parent = v for i, b in pairs(backup:GetChildren()) do if b.Name ~= a.Name then b:Destroy() else b.Name = "Part".. tostring(tonumber(string.sub(a.Name,5)) - 1) b.Parent = v b.CFrame = b.CFrame * CFrame.new(0,0.4,0) if not b:FindFirstChild("Value") then a:WaitForChild("Value").Parent = b else a:WaitForChild("Value"):Destroy() end end end end backup:Destroy() end end end end print("pinato") spawn(autoRespawn) --]] end