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

Is it possible to spawn a meshpart using scripts?

So i found a mesh of a circle that i can use to change it's scale through scripting but i can't seem to spawn the meshpart the way you would normally spawn a part.

	
    local mesh = Instance.new("MeshPart")
	mesh.MeshId = "rbxassetid://2425219842"
	mesh.Transparency = 0.5
	mesh.CanCollide = true
	mesh.Anchored = true
	mesh.Size = Vector3.new(20, 1, 1)
	mesh.Parent = game.Workspace

My objective is to script a flat circle using meshes.

3 comments

0

Yes but you can't set the MeshId through a script.

0

So how would i be able to set it?

0

Just put a premade mesh in ReplicatedStorage or ServerStorage and clone that into the workspace when you need to.

1 answer

✓ Accepted answer

It's impossible to set a MeshPart's MeshId via a script due to the collision model of the mesh not being able to be recomputed during run-time.

One alternative though is something called a SpecialMesh. SpecialMeshes allow for developers to provide a standard template or user uploaded meshes to a BasePart.

You can set the MeshId of a SpecialMesh like so:

local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.FileMesh
mesh.MeshId = "rbxassetid:// " -- Your MeshId here

Another solution would to just store your meshes in ReplicatedStorage and parent them to the workspace/descendant of the workspace whenever you want to use them.

3 comments

0

yeah don't give credit to me for that last method.

0

ok so i was gonna say that before you did but then i decided not to and then i refreshed i saw your reply and thought to add it in anyway lol

0

thanks guys

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