✓ Accepted answer
There are some problems on this script. Right on the beggining you set the Touched event to change the color and material of the block, not destroy it.
script.Parent.Touched:Connect(function()
script.Parent.BrickColor = BrickColor.new("Black")
script.Parent.Material = ("Metal")
end)
With that in mind, your script just checks if the part that holds the script has Metal material as soon as the script runs:
if
script.Parent.Material = ("Metal")
then
script.Parent:Destroy()
wait(0.5)
end
To fix this you should change some of the order on your script. Also set a double = on if script.Parent.Material = ("Metal") and change ("Metal") to Enum.Material.Metal:
script.Parent.BrickColor = BrickColor.new("Black")
script.Parent.Material = ("Metal")
script.Parent.Touched:Connect(function()
if script.Parent.Material == Enum.Material.Metal then
script.Parent:Destroy()
wait(0.5)
end
end)
Do you want the part that holds the script to be destroyed or the part that touched it?
If its the part that touched it, you should give a name to that part inside the function parentheses and use that name to reference it:
script.Parent.BrickColor = BrickColor.new("Black")
script.Parent.Material = ("Metal")
script.Parent.Touched:Connect(function(touchedPart)
if touchedPart.Material == Enum.Material.Metal then
touchedPart:Destroy()
wait(0.5)
end
end)
If you want the part that holds the script to be deleted, change the fifth line to script.Parent:Destroy(). This should work, but if it doesn't, answer me with the error that ocurred on the output window and I will fix it.
1 comment
Also, this is untested so if it doesn't work, ask me.