I am making a strategy game, and I am making a tank corroding when it dies. Every part changes it color and material (except tracks, they mustnt), but unionned part does not (I have UsePartColor
on).
My script:
local tank = script.Parent
local material = Enum.Material.CorrodedMetal
local humanoid = tank:FindFirstChild("Tank")
local color = Color3.fromRGB(80, 58, 23)
local corrodeNames = {
"Hull",
"Armor",
"Turret",
"Cannon"
}
humanoid.Changed:Connect(function(property)
if property == "Health" and humanoid.Health <= 0 then
for _, part in pairs(tank:GetDescendants()) do
if part:IsA("Part") then
if table.find(corrodeNames, part.Name) then
part.Material = material
part.Color = color
end
end
end
end
end)
Photo of tank in explorer and selected union that does not changes.
Photo of tank after it dies (again, union does not changes)
Thanks in advance!