Currently, if you want to replace a mesh with another, you would place in the AssetID or upload the mesh to the meshpart you want to replace.
However, the problem with this is that when uploading the mesh or entering the AssetID, the meshpart resizes to its original size.
I’m posting this because As A Roblox Developer I wanted to easily replace the meshes in my map, however all meshes resize back to the size of the mesh I’m uploading
I’m not sure if this is possible to work around, as everyone relies on meshes uploading with their original size to make sure everything is in-place, but I was just wondering if there could be a possible solution to this.
you could use a simple script in the command bar to get all the meshes you’ve got selected and iterate through them and for each one save the original size and maybe position, then change the mesh and set the size (and position) to the original mesh’s stats.
EDIT: Nevermind, it should work except you can’t use a script to change the mesh ID
Group the parts you want to select into a model (which you already appear to have done)
Run Code Part 1 in the command bar
Select all children of the model and change their MeshId through the explorer
Run Code Part 2 in the command bar
Code Part 1:
local model = workspace.TerrainTest
for _,v in next,model:GetChildren() do
local sizeObj = Instance.new("Vector3Value", v)
sizeObj.Name = "OriginalSize"
sizeObj.Value = v.Size
local cfObj= Instance.new("CFrameValue", v)
cfObj.Name = "OriginalLocation"
cfObj.Value = v.CFrame
end
Code Part 2:
local model = workspace.TerrainTest
for _,v in next,model:GetChildren() do
local sizeObj = v.OriginalSize
v.Size = sizeObj .Value
sizeObj:Destroy()
local cfObj = v.OriginalLocation
v.CFrame= cfObj.Value
cfObj:Destroy()
end
This is only possible in Studio (not in-game) because as you’ve discovered MeshId is only settable via the properties window since Lua can’t modify it.
update:
this method is incompatible with overlapping parts
you could add another value to store its position data?
wait nvm thats actually pretty easy i could do that myself, ill update again using the same code to make a position value
update:
same results apparently. even with a position value the parts dont move back, but the value itself destroys
i just checked and, while the parts look like they’ve just been shifted upwards, they all still keep their position data, which is weird.
is there still hope or is it just impossible at this point
It’s difficult to tell exactly what’s going on in that last picture, since I don’t know what it’s supposed to look like, but in case it’s of any help: when I used a lua script in studio to loop over parts and change their Position or Orientation properties, even just to fix floating point drift, I had to set all the parts to CanCollide = false, then do all the moving/resizing, then set CanCollide back to whatever it was before (I save the original value before setting to false). If I didn’t do this, all the parts that overlapped during the adjustments got piled up vertically.
Setting part.CFrame instead of Position and/or Orientation does not have this issue, and is generally preferable for this reason.
Sorry, I forgot about the position snapping (yet another example of why this awful behavior needs to go). I’ve updated the code in my original post to resolve the issue. You were still experiencing the problem with resetting Position because Position is also subject to the snapping – you need to use CFrame to avoid it.