#Yellow Mine Doesn't destroy

20 messages · Page 1 of 1 (latest)

lost island
#

When i touch the mine, its supposed to destroy, but for some reason, that doesn't happen.

#

Code:

#

local Workspace = game:GetService("Workspace")
local debounce = {}

local function onTouched(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    if humanoid and not debounce[humanoid] then
        debounce[humanoid] = true
        
        for _, child in part:GetDescendants() do
            child:Destroy()
        end

        -- Create an explosion
        local explosion = Instance.new("Explosion")
        explosion.Position = part.Position
        explosion.BlastRadius = 10
        explosion.BlastPressure = 0
        explosion.Parent = Workspace

        -- Apply damage
        humanoid:TakeDamage(5)

        -- Play sound
        local sound = Instance.new("Sound")
        sound.SoundId = "rbxassetid://2674547670"
        sound.Parent = Workspace
        sound:Play()
        
        -- Destroy explosion after a short delay
        task.delay(0.5, function()
            explosion:Destroy()
        end)
        
        -- Destroy the mine
        task.delay(0.1, function()
            if part:IsA("UnionOperation") and part.Name == "Mine" then
                part:Destroy()
            end
        end)
        
        -- Reset debounce after 1 second
        task.delay(1, function()
            debounce[humanoid] = nil
        end)
    end
end

for _, descendant in Workspace:GetDescendants() do
    if descendant:IsA("UnionOperation") and descendant.Name == "Mine" then
        descendant.Touched:Connect(onTouched)
    end
end```
#

Video:

mild bramble
#
for _, child in part:GetDescendants() do 
child:Destroy()
end``` is this the part that destroys the rest of the mine?
#

What is mine? a model? a part?

#

why dont you destroy the part, why the descendants

#

@lost island

lost island
mild bramble
#

destroy the main part

#

it'll be fine

lost island
#

aight ok

mild bramble
lost island
#

I’m not home so I’ll implement it when I can

mild bramble
#

sure sure

#

passed the descendant to function

#

so you dont hv to search for it

#

through workspace