I'm making a wall where if the player touches a part of it, it deletes that section and regenerates later on by creating a clone of it, and the initial wall works as expected. The problem is, the clones don't seem to be affected by the deleting code (they regenerate but don't get deleted when the player touches them). I've tagged all parts of the wall together since they essentially have the same behavior. Here's the script:
local CollectionService = game:GetService("CollectionService") local woodwalls = CollectionService:GetTagged("WoodWall") for _, TaggedPart in pairs(woodwalls) do local model = TaggedPart local enabled = true local clone = model:Clone() TaggedPart.Touched:Connect(function(hit) if enabled == true and hit.Parent:FindFirstChild("Humanoid") then enabled = false model:Destroy() wait(20) local lclone = clone:Clone() lclone.Parent = game.Workspace model = lclone enabled = true end end) end
I would really appreciate any help (preferably in the form of a code snippet rather than just general advice or links).