I have a game with a massive gondola ski lift. I have already laid out all the gondolas in their respective spots. However, i have been working on one and i made a better door opening system. Is there a way to quickly replace all other gondolas with this new one that has the system?
There are a lot of them, about 40-50 of them and replacing them by hand would take quite some time.
this is to visualize just how long the lift is. Placing the gondolas in the first place already took long enough (i built this lift in stages, and extended it over time. It has 3 right now and most likely will have more)
So is there any effective method of replacing all instances of older types of parts with new ones quickly?
26000 studs does not equal 6482 kilometers. One stud equals ~0.28 meters. So, 26,000 studs become 7.28 kilometers.
For the actual question. You can use scripts. Something like:
for _,gondola in game:GetService("Selection"):Get() do
local clone = workspace.NewGondola:Clone()
clone.Parent = gondola.Parent
clone:PivotTo(gondola:GetPivot())
gondola.Parent = workspace -- Parenting to workspace in case the script has a bug.
end
The above script is meant to be run in the command bar. So, do that.
Below is a script to replace all gondola’s with a new gondola with respect to orientation. I already tried it in my game and it worked.
Change the “partA” and “partB” to their respective model names. partA being the old gondola and partB being the new gondola.
Place one “partB” in your game.
Make sure each model has a primary part called “partA” and “partB” respectively.
Then, paste the code in the command line.
-- This script should be run in the Studio Command Bar (not during play)
-- Find all models named "partA" with PrimaryPart
local partAModels = {}
for _, descendant in ipairs(game:GetDescendants()) do
if descendant:IsA("Model") and descendant.Name == "partA" and descendant.PrimaryPart then
table.insert(partAModels, descendant)
end
end
-- Find the original "partB" model with PrimaryPart
local originalPartB = nil
for _, descendant in ipairs(game:GetDescendants()) do
if descendant:IsA("Model") and descendant.Name == "partB" and descendant.PrimaryPart then
originalPartB = descendant
break
end
end
if not originalPartB then
warn("No model named 'partB' with a PrimaryPart was found.")
return
end
-- Replace each partA with a clone of partB
for _, partA in ipairs(partAModels) do
local clone = originalPartB:Clone()
clone.Parent = partA.Parent
clone:SetPrimaryPartCFrame(partA:GetPrimaryPartCFrame())
partA:Destroy()
end
print("Replaced " .. #partAModels .. " partA models with clones of partB.")