Materials is not going on special meshes

So. Materials cant go on special meshes, so theres no way to make a mesh directly from code with materials on. its either i cant set the meshid property for meshparts or i cannot access materials with special meshes when the simpliest fix could be applied to both without changing what they were meant to be. every attack in my game including meshes and vfx is made using a script. instance.news, no cloning.

is there any way to get the image id of materials to use on textures, because this is really annoying and i really do not want to clone so i can save space and make a fully code based game.

an attack i made: the crater doesnt have the material of the floor im on so it looks out of place, (this attack doesnt use any sort of cloning)

1 Like

It’s not necessary to create a mesh in your script. Make a MeshPart, put it in a storage location, and copy it when you trigger the animation. This allows Studio to compute the mesh collisions beforehand and you can still set the material to whatever you want.

image

i just dont get the reason why i cant do this, i only wanted to make attacks fully based on code and not premade waiting to be cloned

You’re really not taking any shortcuts in code by using

NewMesh = StoredMesh:Clone()

instead of

NewMesh = Instance.new("MeshPart")
MeshID = 1234

I don’t quite understand your dilemma.

if you can’t set mesh id and materials, maybe roblox has some limitations about instances and meshes

its not the shortcutssss or convenience, its that i do not want to clone anything and make my attacks script based only

theres no way to get the image of the material
, there must be some way roblox applies materials to parts, like i know they must use an image of some sort like a texture to apply onto all sides

For windows users, the normal, displacement, specular, and bump texture maps are located in
Users\USER\AppData\Local\Versions\VERSION\PlatformContent\pc\textures\

Beggars can’t be choosers. Roblox does not support creating MeshParts during runtime, you’ll have to deal with it by cloning a stored MeshPart (to reiterate, you are only saving yourself from a single line of code) or you will just have to apply your own texture to a SpecialMesh. There aren’t any other options until Roblox supports calculating mesh collisions during runtime, which could be indefinite.

Yeah don’t do that

Making an entirely new instance is much less optimized then cloning it

I don’t get the point in boiler-plating Meshparts’ functionality just to make everything script-based, you’re losing control and it’s going to make your life 100x harder to customize later on

4 Likes

its just for the challenge, not the convenience

1 Like

ill just use no materials, i just really despise cloning.

You could copy the material’s textures, upload them as images and assign their IDs to the ‘TextureId’ properties of your SpecialMesh's.

1 Like

This actually isn’t true, instancing/cloning have essentially the same performance impacts & efficiencies.

local Workspace = workspace

local StartTime = os.clock()

local TemplatePart = Instance.new("Part")
TemplatePart.BrickColor = BrickColor.Random()
TemplatePart.Orientation = Vector3.new(math.random(), math.random(), math.random())
TemplatePart.Position = Vector3.new(math.random(), math.random(), math.random())
TemplatePart.Size = Vector3.new(math.random(), math.random(), math.random())

for _ = 1, 500 do
	local Part = TemplatePart:Clone()
	Part.Parent = Workspace
end

local EndTime = os.clock()
print(EndTime - StartTime) --0.006132900000011432
local Workspace = workspace

local StartTime = os.clock()

local TemplatePart = Instance.new("Part")
TemplatePart.BrickColor = BrickColor.Random()
TemplatePart.Orientation = Vector3.new(math.random(), math.random(), math.random())
TemplatePart.Position = Vector3.new(math.random(), math.random(), math.random())
TemplatePart.Size = Vector3.new(math.random(), math.random(), math.random())

for _ = 1, 500 do
	local Part = Instance.new("Part")
	Part.BrickColor = TemplatePart.BrickColor
	Part.Orientation = TemplatePart.Orientation
	Part.Position = TemplatePart.Position
	Part.Size = TemplatePart.Size
	Part.Parent = Workspace
end

local EndTime = os.clock()
print(EndTime - StartTime) --0.005933499999628111
1 Like

man, i was hoping there would be a function where i could get the material image from a line of code but i guess theres no way to really do that

You should be able to find them by heading over to the ‘TerrainTools’ directory of your %appdata%'s directory.

C:\Users\{Username}\AppData\Local\Roblox\Versions\version-{VERSION}\content\textures\TerrainTools

The files you’re looking for follow a ‘mtrl_{Material Name}.png’ naming scheme.