Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i change a mesh texture and id when it is made with instance.new?

this script is in the button which makes the meshpart appear:

script.Parent.MouseClick:Connect(function()
	local mpart = Instance.new("MeshPart",game.Workspace)
	mpart.Position = Vector3.new(236.04, 81.46, 36.46)
	mpart.MeshId = "rbxassetid://1107996700"
	mpart.TextureID = "rbxassetid://1107996710"
	mpart.Size = Vector3.new(4, 5, 5)
end)

when the meshpart appears it doesnt have the texture or mesh, its just the blank part and i need it to have the texture and meshid. thanks

1 comment

0

you cant assign a MeshId to a MeshPart after running the game sadly, use a SpecialMesh instead

1 answer

Do this instead

	script.Parent.MouseClick:Connect(function()
		local mpart = Instance.new("SpecialMesh",game.Workspace)
		mpart.Position = Vector3.new(236.04, 81.46, 36.46)
		mpart.MeshType == Enum.MeshType.FileMesh
		mpart.MeshId = "rbxassetid://1107996700"
		mpart.TextureID = "rbxassetid://1107996710"
		mpart.Scale = Vector3.new(4, 5, 5) -- changed size to scale because meshes don't have sizes
	end)

3 comments

0

Idk if the TextureID serves any purpose because i haven't tested this out yet but if it creates an error then remove it, else just keep it.

0

SpecialMesh should be parented under a part, not workspace

0

Get rid of the 3rd and 4th lines. SpecialMeshes doesn't have a Position property, it will return an error. And since you've created a SpecialMesh, you don't need to specify type FileMesh. Also, TextureID will return an error. Use TextureId instead (lowercapital "d").

This discussion is preserved as it was. New answers, comments, and votes are closed.