How do i unAnchor Groups with a specific name?

Hello,

After i finish building, i anchor everything by selecting workspace, but i have to unanchor groups and a part to make it work.

How do i make the script the following:

When i anchor everything and i join the game, Parts and Groups Called “Original” will be unAnchored.

The code given above is incorrect due to the fact that it checks the name of each descendant and not the group, so you’d need to have multiple parts having the same name.

For groups:

You loop through workspace:GetDescendants() and check if it is a model and if yes, check its name. If it qualifies for being unanchored then you loop through that model and unanchor each part, or if its a base part you want to unanchor.

Here’s an example:

for i, desc in pairs(workspace:GetDescendants() do
    if desc.Name == "UnAnchorName" then
        if desc:IsA("Model") then
            for _, part in pairs(desc:GetDescendants() do
                if part:IsA("BasePart") then
                    part.Anchored = false
                end
            end
        elseif desc:IsA("BasePart") then
            desc.Anchored = false
        end
    end
end
2 Likes

the 2 “do” gives errors

for i, desc in pairs(workspace:GetDescendants()) do
    if desc.Name == "UnAnchorName" then
        if desc:IsA("Model") then
            for _, part in pairs(desc:GetDescendants()) do
                if part:IsA("BasePart") then
                    part.Anchored = false
                end
            end
        elseif desc:IsA("BasePart") then
            desc.Anchored = false
        end
    end
end

try this

1 Like

It was 2 brackets, and I typed that on mobile

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