UnionAsync not working

local otherparts = Part:GetTouchingParts()
** local OtherPartsTABLE = {}**
** local WATER_COUNT = 0**
** local Grass_Count = 0**
** for i ,v in pairs(otherparts) do**
** if v:IsDescendantOf(workspace:FindFirstChild(player.Name…" STUFF"):FindFirstChild(“Terrain”)) then**
** table.insert(OtherPartsTABLE,v)**
** end**
** end**
** for i ,v in pairs(OtherPartsTABLE) do**
** print(v.Name…" is parented to “…v.Parent)**
** end**
** local newUnion = Part:UnionAsync(OtherPartsTABLE)**
** for i ,v in pairs(OtherPartsTABLE) do**
** if v:FindFirstChild(“MAT”) ~= nil then**
** if v.MAT.Value == “Grass” then**
** Grass_Count = Grass_Count + 1**
** elseif v.MAT.Value == “Water” then**
** WATER_COUNT = WATER_COUNT + 1**
** end**
** end**
** end**
** for i ,v in pairs(OtherPartsTABLE) do**
** workspace.Terrain:FillBlock(v.CFrame , v.Size , Enum.Material.Air)**
** v:Destroy()**
** end**
** Part:Destroy()**
** newUnion.Parent = workspace:FindFirstChild(player.Name…” STUFF"):FindFirstChild(“Terrain”)**
** newUnion.Name = “Block”**
** newUnion.Transparency = 1**
** newUnion.Anchored = true**
** newUnion.CanCollide = false**
** local new = Instance.new(“StringValue” , newUnion)**
** new.Name = “MAT”**
** local mat **
** if Grass_Count > WATER_COUNT then – grass wins**
** mat = “Grass”**
** elseif Grass_Count < WATER_COUNT then – water wins**
** mat = “Water”**
** elseif Grass_Count == WATER_COUNT then – equivellant**
** mat = “Grass”**
** end**
** new.Value = mat**
** workspace.Terrain:FillBlock(newUnion.CFrame , newUnion.Size , Enum.Material[mat])**

image

1 Like