Problem with UnionAsync()

I’m trying to make a script that when hovered over a part that has been tagged, it will create a selection around it. Similarly to miners haven.

I tried to make it so when there’s a model tagged, it loops trough all of its descendants and creates a table of all parts within that model.

And I wanted to union them all together so I can simply adorn the selection box to the union.

It doesn’t say any errors but its just not working.

ServerScript:

script.Parent.Union.OnServerInvoke = function(plr, Union : BasePart, Parts)
	local result = Union:UnionAsync(Parts)
	print(result)
	if result then
		return result
	end
	return
end
  1. The function signature had an unnecessary type annotation (: BasePart). It’s not required since the type is already specified when defining the remote function on the client side.

  2. I removed the conditional check for if result then because the UnionAsync method will either return a unioned part or raise an error if the operation fails. So it’s not necessary to check for a truthy value.

  3. I simplified the return statement. Instead of return alone, you can directly return the result variable.

script.Parent.Union.OnServerInvoke = function(plr, Union, Parts)
    local result = Union:UnionAsync(Parts)
    print(result)
    return result
end

this sounds like its made in chatgpt fr

Did it work and if so can i get the solution

bro you’re just farming solutions

I have one soloution wdym

character limit

It appears that you are attempting to combine multiple parts into a single union using the UnionAsync method. But it’s unclear from your code what Parts stands for, maybe that’s why it isn’t working. From my experience with UnionAsync, you need to pass in an array of BaseParts that you want to union together.

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