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 6 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
6 years ago
Edited 6 years ago

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

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

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):

local centre = model.PrimaryPart
for _,part in pairs(model:GetDescendants()) do
   if part:IsA("BasePart") and part ~= model.PrimaryPart then
      local weld = Instance.new("Weld")
      weld.Part0 = model.PrimaryPart
      weld.Part1 = part
      weld.C1 = part.CFrame:toObjectSpace(model.PrimaryPart.CFrame)
      weld.Parent = model.PrimaryPart
   end
end
0
Thanks LennonLight 95 — 6y
Ad

Answer this question