How to turn a custom hat model into a mesh while keeping different colors and materials?

Alright so I have a custom hat MODEL that is made up of unions. I tried to save it as .obj and make it a mesh in blender to make it a usable hat but it made the entire thing one material, but I need it to have multiple materials and colors for the design, and it has to be a mesh to work with the Handle basepart and so I can character:AddAccessory with it.

How can I make it a mesh for a hat while keeping the different colors and materials?

local hat = game.ServerStorage.Hats.Test
local j_a = 1

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
		if j_a == 1 then
			j_a += 1
		elseif j_a > 1 then
			plr.CharacterAppearanceLoaded:Connect(function(character)
				local humanoid = character:WaitForChild("Humanoid")
				humanoid:RemoveAccessories()
				wait(1)
				humanoid:AddAccessory(hat)
			end)
		end
	end)
end)

image

You can use the hat even if it is made out of unions, but you will have to add welds to every part. The only thing is, you have a lot of unions which may cause performance issues, I would recommend using meshes. To get multiple parts from one mesh, open your hat in blender, go to edit mode and select the faces you want to separate from the mesh, then press “P” and then click “Selection”. If the separation process doesn’t work for you, you might want to check your blender settings. By default it is set to “P”.
After importing it to Roblox Studio, you will have to pick the base of the hat and rename it to “Handle”, then you can add WeldConstraints to each separated part, then open the properties window and set Part0 to Handle and Part1 to the the part you are attaching it to.

If you want to add more polygons to your hat, just use the knife tool. If you want to make it look very smooth, select your hat in blender and then click on the object (located in the left side of your screen) > Shade smooth, then click on the “green triangle” (located in the right side of your screen), open the normals tab and set Auto smooth to true, then play around with the Auto smooth number to get the desired look of your hat. If your hat looks weird, add more polygons by using the knife tool.

If you need more information about welds, check this out :
https://developer.roblox.com/en-us/api-reference/class/WeldConstraint

Hope it helps.

would be better to mesh it in Blender to begin with, importing it to blender to just export wont fix the terrible triangle count unions have, Roblox’s textures are stored locally, so can just take them to import to blender to texture the finished hat.