How do I replace a bunch of meshes

Hi, I’m wondering if there is a way that I can replace a bunch of mesh trees that I have with newer versions without having to do them one by one. I’m not sure if this is possible but if it is it would be great if you could tell me how!

7 Likes

Depends on how this is set up. Should be easy enough from the Studio by hand anyways.
You’re just dropping in new meshes, but you would want to also adjust them.

2 Likes

Are they different sizes? You can try cloning the new tree into the same CFrame as every other tree, and then removing the old tree after you have cloned the new one.

3 Likes

They’re all the same size, but how would I make it so that it would clone into all the trees?

3 Likes

Can you show your file structure where the trees are and where your new mesh is located …

3 Likes

All the old meshes are all located in a file under workspace and are all named the same thing. The new mesh is located just directly under workspace.

2 Likes

I’m assuming you wish to replace all meshes in the trees folder with the new mesh.
Make sure you save before you run anything like this … (not tested)

(may not be what you are looking to do here)
This is looking for anything by the targetname in the tree folder and replacing it with the new mesh.

task.wait(4)
local targetname = "oldmeshname" -- Replace with the actual old mesh name
local trees = workspace:WaitForChild("Trees") -- Replace with the actual folder name
local newMesh = workspace:WaitForChild("mesh")  -- Replace with the actual mesh name

if trees and newMesh then 
	local descendants = trees:GetDescendants()
	for _, descendant in ipairs(descendants) do
		
		print(descendant)
		if descendant.name == targetname then
			local newMeshClone = newMesh:Clone()
			descendant:Destroy() -- if you're brave
			newMeshClone.Parent = descendant.Parent
           --(this last part may be wrong)
		end
	end
end

myself, I would never trust this and do it all by hand …

3 Likes

So I’m assuming I would run this in a server script which the only problem with that is it wouldn’t be permanent. If I were to delete the script then the old trees would just stay there. Or would I try and run this in the command bar?

2 Likes

prob have to do it every time … no way around it … do it by hand.
And it also depends on the mesh type … may not work at all.

1 Like

select all of the trees and you can change the meshID property, get the ID of your new tree mesh on inventory and paste it there, and itll change that property from all of the trees. No need to do it 1by1

3 Likes

This is what I’m saying … just light em up and change them

2 Likes

wait lemme try this, if it works imma look stupid

2 Likes

Roblox Studio is no Joke … as powerful as any other. Has all the bells and whistles.

3 Likes

This seems to have worked thank you, lol

4 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.