Can somone help me real quick with this command bar

So I’m trying to use the command bar to create unions for all theae building so i can make a render distance

For example

For i, v in pairs(workspace:GetDeacendants()) do
If v:IsA(“Part”) then
If v.Parent.Name == “Ice” then

Local New = instance.new(“Part”)
Part.Parent = v.Parent
New.Position = v.Position
New.Transparency = 1

Local new3 = New:UnionAsync(v)

End
End
End

The problem is that it says “unable to cast value to objects”

:man_shrugging:t5:

it was suposed to be “Part.Parent”? (or “New.Parent”?)

It supposed to be New.Parent =v.Parent, i had a typo there, my bad

v is a single Part. You can’t union a part with a single part, only a list of parts 1. Try

EDIT: I made a mistake, the following is edited to hopefully fix that xD

local firstPart
local parts = {}
For i, v in pairs(workspace:GetDeacendants()) do
If v:IsA(“Part”) then
If v.Parent.Name == “Ice” then

Local New = instance.new(“Part”)
Part.Parent = v.Parent
New.Position = v.Position
New.Transparency = 1

if i == 1 then
firstPart = New
else
table.insert(parts, New)
end
End
End
End
Local new3 = firstPart:UnionAsync(parts)
new3.Parent = game.Workspace --probably needed?

Obviously you’ll need to fix the capitalization on all the keywords. You can post properly formatted code by putting it between 2 x 3 backticks. E.g.

```
print(“Hi”)
```
becomes

print("Hi")

I think I explained this wrong, Lemme see if I can reword it. I have a model (IceSpike) inside of another model (IceModel) and IceSpike has tons of parts in it, is there a way to turn all the parts that are in ice into a union all at once? But there are many other duplicates of IceSpikes.

you made a typo in :GetDescendants()