How to make decals disappear

I’ve made it to where a crowbar can break the wooden planks successfully when you touch it. The thing now is that since I have decals on the wooden planks, they don’t disappear along with the parts, is there anything that I can implement to the script so the decals go away too?

image

image

image

You can simply loop through the children of the part and check if it’s a Texture or Decal.

What would that look like? Sorry, I don’t have that much knowledge in scripting

You could just reference through all of the Decals inside a loop when the Touched event is called successfully:

for _, Object in pairs(script.Parent:GetChildren()) do
    if Object:IsA("Decal") then
        Decal.Transparency = 1 --I forgot the transparency property for the Decal
    end
end

Basically, Object would be the current object inside the first loop, then the second time it loops it would be referenced as a different Object

This is simply known as a for i, v in pairs loop which iterates through the entire table of objects & checking if each object is exact to what you want

function ontouch(hit)
local CrowbarKey = hit:FindFirstChild('CrowbarKey')
if not CrowbarKey then return end

hit.Parent:Destroy()
script.Parent.Transparency = 1
script.Parent.CanCollide = false

for _, decal in pairs(script.Parent:GetChildren()) do
if decal:IsA('Decal') or decal:IsA('Texture') then
decal.Transparency = 1
end
end
end

script.Parent.Touched:Connect(ontouch)
2 Likes

Thank you!! It worked exactly how I wanted it to :slight_smile: