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
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.
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.
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
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.