Editablemesh issue

Hiii im trying to make so you can see the vaertices of the mehs inside of the game. I know the instance.new(“Part”) should set its property but i need help. I appreciate every single answer :D’

local AssetService = game:GetService("AssetService")
local RunService = game:GetService("RunService")

local object = script.Parent.Parent:WaitForChild("HaloMesh")
local editableMesh = AssetService:CreateEditableMeshFromPartAsync(object)
editableMesh.Parent = object

local vertices = editableMesh:GetVertices()

for _, vertice in ipairs(vertices) do
	local k = Instance.new("Part")
	k.Parent = object
	k.Position = Vector3.new(vertice.x, vertice.y, vertice.z)
end

At least read the API Docs first before asking. Your answers are in there and it’s way faster to look it up yourself instead of asking on the forum which would usually take hours to get a response.

But I still condensed it down for you:

:GetVertices() returns the ID of vertices, not the vertices themselves. Your code will error because you are trying to index a number.

:GetPosition(id) is what you should use afterward, it gives you the position of the vertex after you give it the ID.

Lastly, vertex position is in objectspace, meaning it is relative to the mesh itself. If you want to convert to worldspace, use this example:

k.CFrame = mesh.CFrame * CFrame.new(vertexPosition)
1 Like