How do I make a part destroy?

How do I make it so when the player clicks on an item the whole part will disappear for around 10 minutes as well as decals inside. And it can’t be clicked anymore.

I suggest watching a few tutorials on scripting, we cannot spoon feed you answers. At least get some form of script before posting here for help.

2 Likes

You should do:

local MouseClickDetector = script.Parent.ClickDetector-- Setting a click detector a var

MouseClickDetector.MouseClick:Connect(function() -- Event of mouse detector
        script.Parent.Transparency = 1 -- setting part transparency to 1, making it invisible
        
        for i, v in pairs(script.Parent:GetChildren()) do
                if v:IsA("BasePart") then
                     v.Transparency = 1
              end
        end
end)


-- Just do wait(10 minutes in milseconds)

-- and do the same and switch the transparency to 0.

As @PrismaticFruits said, you may first learn scripting b4 asking people to script for you…

1 Like

No, no. I’m just asking for a direction I tried transparency it doesnt do decals.

Look in the developer wiki about deacls, what their propeties.

Decals have a type of transparency property, just look

Transparency has nothing to do with decals.

image So like this?

Yes, that code would execute perfectly.

Some reason it doesnt. No errors on it, probs just a studio error I’ll just restart, Anyways thanks for the help.

You are setting the Part transparency to 1. The decals have their own Transparency and don’t copy their parents property. You will have to define the decals and then their property.

Here.

-- I fixed the script
local Part = script.Parent
function click()
for _, v in pairs(Part:GetDescendants()) do
      if v:IsA("Texture") or v:IsA("Decal") then
                  v.Transparency = 1
            end
       end
end
Part.Transparency = 1
wait(10)
for _, v in pairs(Part:GetDescendants()) do
      if v:IsA("Texture") or v:IsA("Decal") then
                  v.Transparency = 0
            end
       end
end
Part.Transparency = 0
end
clicker.MouseClick:Connect(click)
while true do
    wait(600)
    for _, item in ipairs(part:GetDescendants()) do
         if item:IsA("BasePart") then
             item.Transparency = 1
             item.CanCollide = false
         elseif item:IsA("Decal") then
             item.Transparency = 1
         end
    end
end
1 Like