Hello! I am trying to do a sphere that changes shape using the editable mesh. The “CreateEditableMeshFromPartAsync” was deprecated, breaking this script. I originally got this script from someone else (and modified it with chat gpt a little bit since the constant api changes), and i cannot figure out at all how to get it back working no matter how hard i’ve tried.
Client Script:
local remoteEvent = game.ReplicatedStorage:WaitForChild("MeshUpdateEvent")
local obj = script.Parent --(mesh part)
local editableMesh
local function updateMesh(updatedVertices)
if not editableMesh then
local AssetService = game:GetService("AssetService")
editableMesh = AssetService:CreateEditableMeshFromPartAsync(obj)
editableMesh.Parent = obj
end
for vertex_id, newPosition in pairs(updatedVertices) do
editableMesh:SetPosition(vertex_id, newPosition)
end
end
remoteEvent.OnClientEvent:Connect(function(updatedVertices)
updateMesh(updatedVertices)
end)
Server script:
local remoteEvent = game.ReplicatedStorage:WaitForChild("MeshUpdateEvent")
local obj = script.Parent
local config = {
refreshRate = 0.05,
positionChangeMultiplier = 5
}
local function calculateVertices()
local verticesPosition = {}
local AssetService = game:GetService("AssetService")
local editableMesh = AssetService:CreateEditableMeshFromPartAsync(obj)
local vertices = editableMesh:GetVertices()
for _, vertex_id in pairs(vertices) do
local position = editableMesh:GetPosition(vertex_id)
local displacement = position.Unit * math.noise(
position.X / 10 + os.clock(),
position.Y / 10 + os.clock(),
position.Z / 10 + os.clock()
) * config.positionChangeMultiplier
local newPosition = position + displacement
verticesPosition[vertex_id] = newPosition
end
remoteEvent:FireAllClients(verticesPosition)
end
while true do
calculateVertices()
task.wait(config.refreshRate)
end
Help would be appreciated!
1 Like
Yes AssetService:CreateEditableMeshFromPartAsync
has been deprecated so please use AssetService:CreateEditableMeshAsync
instead:
local meshContent = Content.fromUri(obj.MeshId)
local editableMesh = AssetService:CreateEditableMeshAsync(meshContent)
2 Likes
i guess i need to apply it somehow or something? just cant find a way to doing so…
1 Like
Just substitute your line calling AssetService:CreateEditableMeshFromPartAsync
.
You need a MeshPart with some mesh id in workspace. Make sure you own the mesh associated to that mesh id. You can find all meshes you own at https://create.roblox.com/dashboard/creations?activeTab=Mesh
Local Script:
local remoteEvent = game.ReplicatedStorage:WaitForChild("MeshUpdateEvent")
local obj = script.Parent --(mesh part)
local editableMesh
local function updateMesh(updatedVertices)
if not editableMesh then
local AssetService = game:GetService("AssetService")
local meshContent = Content.fromUri(obj.MeshId)
editableMesh = AssetService:CreateEditableMeshAsync(meshContent)
--editableMesh = AssetService:CreateEditableMeshFromPartAsync(obj)
editableMesh.Parent = obj
end
for vertex_id, newPosition in pairs(updatedVertices) do
editableMesh:SetPosition(vertex_id, newPosition)
end
end
remoteEvent.OnClientEvent:Connect(function(updatedVertices)
updateMesh(updatedVertices)
end)
Script:
local remoteEvent = game.ReplicatedStorage:WaitForChild("MeshUpdateEvent")
local obj = script.Parent
local config = {
refreshRate = 0.05,
positionChangeMultiplier = 5
}
local function calculateVertices()
local verticesPosition = {}
local AssetService = game:GetService("AssetService")
local meshContent = Content.fromUri(obj.MeshId)
local editableMesh = AssetService:CreateEditableMeshAsync(meshContent)
--local editableMesh = AssetService:CreateEditableMeshFromPartAsync(obj)
local vertices = editableMesh:GetVertices()
for _, vertex_id in pairs(vertices) do
local position = editableMesh:GetPosition(vertex_id)
local displacement = position.Unit * math.noise(
position.X / 10 + os.clock(),
position.Y / 10 + os.clock(),
position.Z / 10 + os.clock()
) * config.positionChangeMultiplier
local newPosition = position + displacement
verticesPosition[vertex_id] = newPosition
end
remoteEvent:FireAllClients(verticesPosition)
end
while true do
calculateVertices()
task.wait(config.refreshRate)
end
1 Like