Can't change a model descendant material and color

Hi, I’m currently trying to change a model material and color but they don’t work, I already looked at many Devforum posts but can’t seem to find the right one.

This is the script:

			for i, part in pairs(Aircraft:GetDescendants()) do
				if part:IsA("BasePart") or part:IsA("MeshPart") or part:IsA("UnionOperation") then
					part.Material = Enum.Material.CorrodedMetal
					part.BrickColor = BrickColor.new("Dark stone grey")
					print("CRASHED")
7 Likes

Are you sure you are assigning those properties to a Part?

7 Likes

Yeah it’s all properly assigned to the parts. The problem is that it doesn’t fully change all the parts material and color

2 Likes

if its a union you have to turn on a property called UsePartColor.
image
This could fix your issue. About the material i’m not sure.

4 Likes

No, all of them are MeshParts.

2 Likes

well if so then try only

part:IsA("MeshPart")

I mean i don’t see the reason why its not working.

2 Likes

Is there any errors in the output ? And also you only have to use part:IsA(“BasePart”) because BasePart includes parts, meshparts and unions

2 Likes

There are no errors on the output and i tried everything like is a meshpart is a basepart is a unionoperation but it still doesn’t work. It works somehow like this:

image

I had to activate the script 3 times and it makes 3 random parts activated

2 Likes

You can see it successfully made a part material and color change to its objective. But it’s only working one by one.

Could it be my debounce script?

yes it could be it mind showing it or you will check it your self?

1 Like

I tested it, yes it was the debounce. But I need the debounce for my aircraft so the explode sound doesn’t spam. So i don’t really know what i should use

1 Like

I mean you can show it maybe i can find a way. At least you found the issue.!

1 Like

Alright.

local Seat = script.Parent.Seat
local Hitbox = script.Parent.Parent.Body.CollisionPart
local Engine = script.Parent.Parent.VehicleEngine

local ExplosionSmall = script.ExplosionSmall
local ExplosionBig = script.ExplosionBig

local ImpactSoundSmall = script.ImpactSoundSmall
local ImpactSoundBig = script.ImpactSoundBig

local Aircraft = script.Parent.Parent.Parent.AircraftModel

Hitbox.Touched:Connect(function(hit)
	if Seat.Velocity.Magnitude >= 80 and hit then
		ImpactSoundSmall:Play()
		ImpactSoundBig:Play()
		ExplosionSmall:Clone()
		ExplosionSmall.Parent = Engine
		ExplosionSmall:Emit(150)
		ExplosionBig:Clone()
		ExplosionBig.Parent = Engine
		ExplosionBig:Emit(150)
		for i, part in pairs(Aircraft:GetDescendants()) do
			if part:IsA("BasePart") or part:IsA("MeshPart") or part:IsA("UnionOperation") then
				part.Material = Enum.Material.Sandstone
				part.BrickColor = BrickColor.new("Dark stone grey")
			end
		end
	end
end)

Sorry i didn’t see it. Ehm did you already delete debounce or?

Yeah I deleted the debounce cooldown

Do you need the debounce version?

oh man i wasn’t on devfourm sorry ehm if you don’t have debounce do you still have the audio issue that it spams? Cause when i am looking at it i don’t see an issue.

Yeah the audio spams whenever the plane crash. I’m trying to make it stop when still playing

Hitbox.Touched:Oncet(function(hit)

You could try this!