How do I modify the texture of a MeshPart / SpecialMesh?

Hello Devforum,

(This post relates to an earlier post, view it here.)

I’m currently having issues with MeshParts and SpecialMeshes.
I’m trying to modify their textures with server scripts by modifying the Mesh.TextureID, however it just doesn’t work.

I’ve looked at the documentation on MeshParts and TextureIDs, and the parallel says that the property is read-only. Why??

Anyway, I would like to modify the texture of a mesh, however TextureID is read-only, how do I modify the texture?

1 Like

First question is it a mesh part or a special mesh part? And do you have a script you can show?

The script has an if statement to detect if it is a MeshPart or a SpecialMesh, both mesh types have the same TextureID property (here’s a link for the documentation on SpecialMeshes: FileMesh | Documentation - Roblox Creator Hub)

Does it give a certain error?? If so please state it

It gives the error:
TextureID is now a valid member of SpecialMesh/MeshPart "AccessoryName"

Okay well do you have the script can you paste it here?

Here’s the part of the script that is supposed to add the accessory and give it a texture:

			if texid == nil then
				player.Character.Humanoid:AddAccessory(asset)
				print("flood")
			else
				for i, descendant in asset:GetDescendants() do
					if descendant:IsA("MeshPart") then
						descendant.Texture = "rbxassetid://" ..texid
						
					elseif descendant:IsA("Part") then
						local dmesh = descendant:FindFirstChildOfClass("SpecialMesh")
						dmesh.Texture = "rbxassetid://" ..texid
					else
						error("oh noes")
					end
				end
				print("boat")
			end
		end```

Wait is the texid supposed to run if its nil?

The detection for nil is to prevent it from writing in a texture if there wasn’t one given.
If the value isn’t nil, then it runs the code to change the texture alongside adding the accessory.
(texid is the value of which the texture is written to.)

Does this work with a normal mesh?

I would assume not, as they likely use the same .TextureID as both meshparts and specialmeshes, and this value is listed as read-only in the official documentation, however I haven’t tested this (as accessories only use meshparts or specialmeshes)

Wait you are using .Texture you have to use .TextureId unless if Texture is a var you made?

Sorry, I was doing some testing with just .Texture instead of .TextureID, but I have confirmed that .TextureID does not work.

Well it seems that .TextureId works on special meshs, But I don’t know this might be a bug because I cant even change the texture of a meshpart without a script

I’ve searched on Google and have found this.
It’s a post explaining essentially the same problem however it uses .Texture and not .TextureID, it also uses a pre-determined TextureID in a script, however the textureID here is one given by the player.
If neither of us can solve it, I’ll try to message the creator of that post to see if they still have the answer.

Alright good to know sorry if i wasn’t a big help

1 Like

That’s completely fine, thanks for trying.