How do I modify this crater script so it changes material and color when touching a part with corresponding material and color

Hello Developers!

I’ve decided to write some code from a Roblox Video tutorial which showcases those pretty fancy craters/rock shockwaves. The only issue is that I am wondering how to make it so that whenever it touches a part with a certain material and color, the rocks from it will change to the corresponding material and color. (For example, the rocks from the crater material will be brick if it’s touching a part with the brick material.)

local Part = script.Parent
local CFR = Part.CFrame
local Angle = 0

task.wait(8)
for i=0, 15 do
	local Size = math.random(2,4)
	local RockPart = Instance.new("Part")
	RockPart.Anchored = true
	RockPart.CanCollide = false
	RockPart.CastShadow = false
	RockPart.Size = Vector3.new(Size, Size, Size)
	RockPart.CFrame = CFR * CFrame.fromEulerAnglesXYZ(0, math.rad(Angle), 0) * CFrame.new(0, -Size, -10)
	RockPart.Orientation = Vector3.new(math.random(-180,180), math.random(-180,180), math.random(-180,180))
	RockPart.Parent = game.Workspace

	local Tween = game:GetService("TweenService"):Create(RockPart,TweenInfo.new(.5),{Position = RockPart.Position + Vector3.new(0,Size,0)}):Play()

	delay(5,function()
		local Tween = game:GetService("TweenService"):Create(RockPart,TweenInfo.new(.5),{Transparency = 1})
		task.wait(1)
		RockPart:Destroy()
	end)

	Angle += 24
end