Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you unanchor a model?

Asked by 7 years ago

How would you unanchor a model.. Would you set the primary part's anchored value to unanchored? :/

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

If you need to unanchor all parts within the model, you can paste this script into the command bar:

1local modelName = "" --add model name inside quotes
2local model = workspace:FindFirstChild(modelName,true)
3for _,part in pairs(model:GetDescendants()) do
4   if part:IsA("BasePart") then
5      part.Anchored = false
6   end
7end

If you want to keep the parts inside the model connected together, however, you would need to use a weld script, which may look something like this (continuing from the last script):

01local centre = model.PrimaryPart
02for _,part in pairs(model:GetDescendants()) do
03   if part:IsA("BasePart") and part ~= model.PrimaryPart then
04      local weld = Instance.new("Weld")
05      weld.Part0 = model.PrimaryPart
06      weld.Part1 = part
07      weld.C1 = part.CFrame:toObjectSpace(model.PrimaryPart.CFrame)
08      weld.Parent = model.PrimaryPart
09   end
10end
0
Thanks LennonLight 95 — 7y
Ad

Answer this question