You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I would like to figure out what causes :UnionAsync to freeze my code in this scenario and fix the issue.
- What is the issue? Include screenshots / videos if possible!
:UnionAsync does not seem to work, there are no errors returned and it seems to freeze my code making “Test2” not print.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried asking chatgpt, who advised me to unpack the variable “OtherMatrixLines” in the :UnionAsync but that gave an error.
I have also tried reducing “MatrixWidth” to 6 to see if it is the amount of parts, which does not seem to be the issue.
I tried looking for “:UnionAsync not working” and similar phrases on google and the dev forum and have found barely any, and they do not seem to apply to my case.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I don’t know how to best give an example without showing all my code so…
There is a RemoteEvent called CreateMatrixGridEvent in ReplicatedStorage.
type: LocalScript, Position: StarterPlayerScripts
local MatrixWidth = 35
local MatrixHeight = MatrixWidth * 2
local PrepDistance = 1
local MatrixLineAmount = MatrixWidth - PrepDistance
local MatrixClimb = "placeholder"
local Matrix = Instance.new("Folder")
Matrix.Parent = game.Workspace
Matrix.Name = "Matrix"
local MatrixLineSpaces = MatrixLineAmount - 1
local MatrixLineDistance = (MatrixWidth - PrepDistance * 2) / (MatrixLineSpaces)
local MatrixLineAmountY = math.floor((MatrixHeight - PrepDistance * 2) / MatrixLineDistance)
local PrepDistanceY = (MatrixHeight - (MatrixLineAmountY * MatrixLineDistance)) / 2
local HalfWidth = MatrixWidth / 2
local HalfHeight = MatrixHeight / 2
local Vector3SizeX = Vector3.new(0, MatrixHeight, MatrixWidth)
local Vector3SizeY = Vector3.new(MatrixWidth, 0, MatrixWidth)
local Vector3SizeZ = Vector3.new(MatrixWidth, MatrixHeight, 0)
local PartDataString = ""
for I = 0, MatrixLineSpaces do
PartDataString = PartDataString..tostring(Vector3.new(PrepDistance + I * MatrixLineDistance - HalfWidth, 0, 0))..";"..tostring(Vector3SizeX).."│"
PartDataString = PartDataString..tostring(Vector3.new(0, 0, PrepDistance + I * MatrixLineDistance - HalfWidth))..";"..tostring(Vector3SizeZ).."│"
end
for I = 0, MatrixLineAmountY do
PartDataString = PartDataString..tostring(Vector3.new(0, PrepDistanceY + I * MatrixLineDistance - HalfHeight, 0))..";"..tostring(Vector3SizeY).."│"
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CreateMatrixGrid = ReplicatedStorage:WaitForChild("CreateMatrixGridEvent")
CreateMatrixGrid:FireServer(PartDataString)
type: ServerScript, Position: ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CreateMatrixGrid = ReplicatedStorage:WaitForChild("CreateMatrixGridEvent")
CreateMatrixGrid.OnServerEvent:Connect(function(Player, PartDataString)
local TempFolder = Instance.new("Folder")
TempFolder.Parent = game.Workspace
TempFolder.Name = "TempFolder"
for I, V in string.split(PartDataString, "│") do
if V ~= "" then
local MatrixLineData = {}
for StoredData in string.gmatch(V, "[^;,]+") do
table.insert(MatrixLineData, StoredData)
end
local MatrixLine = Instance.new("Part")
MatrixLine.Anchored = true
MatrixLine.Transparency = 0
MatrixLine.Position = Vector3.new(tonumber(MatrixLineData[1]), tonumber(MatrixLineData[2]), tonumber(MatrixLineData[3]))
MatrixLine.Size = Vector3.new(tonumber(MatrixLineData[4]), tonumber(MatrixLineData[5]), tonumber(MatrixLineData[6]))
MatrixLine.Parent = TempFolder
end
end
local FirstMatrixLine = TempFolder:GetChildren()[1]
local OtherMatrixLines = TempFolder:GetChildren()
table.remove(OtherMatrixLines, 1)
print("Test1")
local success, MatrixGrid = pcall(function()
return FirstMatrixLine:UnionAsync(OtherMatrixLines)
end)
if success then
print("Union succeeded.")
else
print("Error in union: " .. MatrixGrid)
end
print("Test2")
end)
Here is an image of what it Currently does :
What i would like for it to do is convert the “block” into a union
This is my first forum Post too, so i hope this was clear on what i wish to achieve, my issues, and what i have tried
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.